+ Reply to Thread
Results 1 to 2 of 2

Thread: printing treeview!!!

  1. #1
    bennettfan is offline VB.NET Forum Newbie bennettfan is on a distinguished programming path ahead
    .NET Framework
    .NET 2.0
    Join Date
    Jan 2010
    Age
    21
    Posts
    11
    Reputation
    8

    Default printing treeview!!!

    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?

  2. #2
    bennettfan is offline VB.NET Forum Newbie bennettfan is on a distinguished programming path ahead
    .NET Framework
    .NET 2.0
    Join Date
    Jan 2010
    Age
    21
    Posts
    11
    Reputation
    8

    Default

    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() ??

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts