printing treeview!!!

bennettfan

Member
Joined
Jan 31, 2010
Messages
11
Programming Experience
Beginner
Printing the .NET TreeView Control - CodeProject

In this link, once I type it into VB 2008,

"this._controlImage = GetImage(tree.Handle, tree.Width, tree.Height)"
//reset the tree to its original settings

this statement just has error and I think that "this._controlImage" , the treeview may not have "_controlImage" member. So, what is the case?

Also, I search that the method "GetImage()"....

It shoubld be
"ToolboxBitmapAttribute.GetImage Method (Type, String, Boolean)"....

So, tree.Handle is the Type?
tree.Width is String?
tree.Height is Boolean?

or GetImage Method should have other parameter??

or does anyone can give me other link or teach me help to print a treeview?
 
Private Sub PrepareTreeImage()
Dim _scrollBarWidth As Integer
Dim _scrollBarHeight As Integer
Dim height1 As Integer
Dim node1 As New TreeNode
Dim width1 As Integer

_scrollBarWidth = tvwLanguages.Width - tvwLanguages.ClientSize.Width
_scrollBarHeight = tvwLanguages.Height - tvwLanguages.ClientSize.Height
tvwLanguages.Nodes(0).EnsureVisible()
height1 = tvwLanguages.Nodes(0).Bounds.Height
tvwLanguages.Height = height1
width1 = tvwLanguages.Nodes(0).Bounds.Right
node1 = tvwLanguages.Nodes(0).NextVisibleNode


While (node1 IsNot Nothing)
Height += node1.Bounds.Height
End While


If (node1.Bounds.Right > width1) Then
width1 = node1.Bounds.Right
End If

node1 = node1.NextVisibleNode




'keep track of the original tree settings

Dim tempHeight As Integer
Dim tempWidth As Integer
Dim tempBorder As BorderStyle
Dim tempScrollable As Boolean
Dim selectedNode As New TreeNode

tempHeight = tvwLanguages.Height
tempWidth = tvwLanguages.Width
tempBorder = tvwLanguages.BorderStyle
tempScrollable = tvwLanguages.Scrollable
selectedNode = tvwLanguages.SelectedNode
'setup the tree to take the snapshot

Dim tempDock As DockStyle
tvwLanguages.SelectedNode = Nothing
tempDock = tvwLanguages.Dock
tvwLanguages.Height = Height + _scrollBarHeight
tvwLanguages.Width = Width + _scrollBarWidth
tvwLanguages.BorderStyle = BorderStyle.None
tvwLanguages.Dock = DockStyle.None
'get the image of the tree


Dim controlImage As Image = Nothing
Dim imageAttr As ToolboxBitmapAttribute = CType(attrCol(GetType(ToolboxBitmapAttribute)), true)

tvwLanguages.controlImage = imageAttr.GetImage(tvwLanguages.Handle, tvwLanguages.Width, tvwLanguages.Height)
' ''reset the tree to its original settings

tvwLanguages.BorderStyle = tempBorder
tvwLanguages.Width = tempWidth
tvwLanguages.Height = tempHeight
tvwLanguages.Dock = tempDock
tvwLanguages.Scrollable = tempScrollable
tvwLanguages.SelectedNode = selectedNode
''give the window time to update

Application.DoEvents()
End Sub


------------------------------------
this is the code I edit to vb2008....and
Dim controlImage As Image = Nothing
Dim imageAttr As ToolboxBitmapAttribute = CType(attrCol(GetType(ToolboxBitmapAttribute)), true)

tvwLanguages.controlImage = imageAttr.GetImage(tvwLanguages.Handle, tvwLanguages.Width, tvwLanguages.Height)
' ''reset the tree to its original settings

this part is getting wrong....
can someone help?

Also, what is the meaning oF Application.DoEvents() ??
 
Back
Top