Results 1 to 2 of 2

Thread: Recursively Map Tree Node Structure

  1. #1

    Thread Starter
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307

    Recursively Map Tree Node Structure

    Hi,

    I'm trying to map a tree-node structure and have been racking my brains for the last couple of hours and need some help.

    I want to output the structure of a tree view including it's sub-nodes to a string, delimited by a colon.

    I have got the code working if the first child nodes do not have any sub-nodes (i.e: root/subnode)

    But if any of the subnodes have children, I get stuck!
    Please help!

    Here's what I have so far.....

    VB Code:
    1. Private Sub mapNodes(ByVal myNode As TreeNode)
    2.  
    3.         Dim subNode As TreeNode
    4.  
    5.         'Are we at a root node?
    6.         If myNode.Tag = "root" Then
    7.             nodeMap = "root:"
    8.         End If
    9.  
    10.         'Iterate through each sub-node.
    11.         For Each subNode In myNode.Nodes
    12.             nodeMap += subNode.Text & ":"
    13.  
    14.             'If this node has children, recurse through them...
    15.             If subNode.GetNodeCount(False) > 0 Then
    16.                 'Stuck here!!
    17.             End If
    18.         Next
    19.  
    20.     End Sub
    "I'm Brian and so is my Wife"

  2. #2

    Thread Starter
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307

    Re: Recursively Map Tree Node Structure

    Just needed to call the function again!
    It's been a long day!!!!

    VB Code:
    1. 'If this node has children, recurse through them...
    2.             If subNode.GetNodeCount(False) > 0 Then
    3.                 mapNodes(subNode)
    4.             End If

    Now I just need to find some way of organising the string so that I can accurately re-populate an empty tree-view with the structure. (this string is held in the registry and will be used to re-populate a tree view at runtime).
    "I'm Brian and so is my Wife"

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