Results 1 to 4 of 4

Thread: Loop through Treeview and print...[Resolved]

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Resolved Loop through Treeview and print...[Resolved]

    For X = 1 To frmMain.tvInstalled.Nodes.Count
    Printer.Print frmMain.tvInstalled.Nodes(X).Text
    DoEvents
    Next

    this works.. sort of.

    What I need is to print the nodes in order with an appropriate indent..

    Looping the above way does not print the nodes out the same as you see them

    loops through each "level" instead of top to bottom...
    Last edited by Static; May 25th, 2005 at 09:05 AM.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Loop through Treeview and print...

    Is this for documentation purposes? If so, then why not just take a screen shot and print that?

    (I ask this question because I had to do this once for a project.)

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Loop through Treeview and print...

    Screenshot doesnt capture all items..
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Loop through Treeview and print...

    Got it.. found this little bit of code on the web
    tweaked it for printing...

    VB Code:
    1. Public Sub PrintTree(objNode As Node)
    2.     Static Indent As Integer
    3.     Dim objSiblingNode As Node
    4.    
    5.     Set objSiblingNode = objNode
    6.    
    7.     Do
    8.         Printer.CurrentX = Indent
    9.         Printer.Print objSiblingNode.Text
    10.         If Not objSiblingNode.Child Is Nothing Then
    11.             Indent = Indent + 500
    12.             Call PrintTree(objSiblingNode.Child)
    13.         End If
    14.         Set objSiblingNode = objSiblingNode.Next
    15.     Loop While Not objSiblingNode Is Nothing
    16.     Indent = Indent - 500
    17.     If Indent < 0 Then Indent = 0
    18. End Sub
    19.  
    20. Private Sub Usage()
    21.     Call PrintTree(Treeview1.Nodes(0))
    22. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

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



Click Here to Expand Forum to Full Width