Treeview nodes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ykhamitkar
    New Member
    • May 2007
    • 64

    Treeview nodes

    Hi there,

    I have a treeview in my ms access form.
    How can I get list of all nodes(Direct or indirect) under any particular node I would select.

    For example my treeview is
    1
    a
    a1
    a2
    b
    2
    x
    x1
    x1.1
    x1.2
    x2

    If my starting point is 1 it should give me list like(May be I would save it in a table)

    1
    a
    a1
    a2
    b

    if my starting point is x then it should give me
    x
    x1
    x1.1
    x1.2
    x2

    Please help

    Thanks,
    Yogesh
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Originally posted by ykhamitkar
    Hi there,

    I have a treeview in my ms access form.
    How can I get list of all nodes(Direct or indirect) under any particular node I would select.

    For example my treeview is
    1
    a
    a1
    a2
    b
    2
    x
    x1
    x1.1
    x1.2
    x2

    If my starting point is 1 it should give me list like(May be I would save it in a table)

    1
    a
    a1
    a2
    b

    if my starting point is x then it should give me
    x
    x1
    x1.1
    x1.2
    x2

    Please help

    Thanks,
    Yogesh
    Hi, Yogesh.

    The most suitable solution is recursive (calling itself) procedure.
    something like this

    Code:
    Public Sub EnumerateChildNodes(nodStart As MSComctlLib.Node)
    
        Dim nodNode As MSComctlLib.Node
        
        Debug.Print nodStart.Text
        If nodStart.Children = 0 Then Exit Sub
        
        Set nodNode = nodStart.Child
        Do
            EnumerateChildNodes nodNode
            Set nodNode = nodNode.Next
        Loop Until nodNode Is Nothing
        
    End Sub

    Comment

    • ykhamitkar
      New Member
      • May 2007
      • 64

      #3
      Originally posted by FishVal
      Hi, Yogesh.

      The most suitable solution is recursive (calling itself) procedure.
      something like this

      Code:
      Public Sub EnumerateChildNodes(nodStart As MSComctlLib.Node)
      
          Dim nodNode As MSComctlLib.Node
          
          Debug.Print nodStart.Text
          If nodStart.Children = 0 Then Exit Sub
          
          Set nodNode = nodStart.Child
          Do
              EnumerateChildNodes nodNode
              Set nodNode = nodNode.Next
          Loop Until nodNode Is Nothing
          
      End Sub

      Thank you so much,

      This works great!!

      Comment

      Working...