Getting the ChildNode info in a Treeview Control:   Return to List

    Option Base 1
    Dim aryChildInfo()
    . . .
    . . .
    ' First we'll acquire the Node Key of the Selected Node
    Set xNod = Treeview1.HitTest(x, y)
    If xNod Is Nothing Then Exit Sub' Generally inside of a Treeview1_MouseDown(...) event, so they could click elsewhere
    Set Treeview1.DropHighlight = xNod' We want to highlight the node
    strKey = xNod.Key' And obtain the key
    ' Now we'll check everything else to see if this is a parent or grandparent (assume 3 levels)
    For i = 1 To Treeview1.Nodes.Count' We'll Loop through ALL the Nodes
        If Treeview1.Nodes(i).Parent.Key = strNodeKey or Treeview1.Nodes(i).Parent.Parent.Key = strNodeKey Then
            lngCount = lngCount + 1
            ReDim Preserve aryChildInfo(2, lngCount)
            aryChildKeys(1, lngCount) = Treeview1.Nodes(i).Key
         aryChildKeys(2, lngCount) = Treeview1.Nodes(i).Text
        End If
    Next
    ' Now we can process the aryChildInfo() array as we see fit

' All nodes in a Treeview have 2 basic properties:
    Node.Text -- The text displayed in the Treeview control
    Node.Key -- The assigned key -- used to attach children & perform other manipulations on the particular node.

See also:
Treeview ... Adding Nodes
Treeview ... Adding Root Node
Treeview ... Collapsing Nodes to Root Level
Treeview ... Complete Subprocedure for Collapsing Nodes
Treeview ... Counting Number of Nodes
Treeview ... Expanding All Nodes
Treeview ... Determing selected Node and Highlighting it
Treeview ... Text of Selected Node
Treeview ... Node Click Event
Treeview ... Number of Children (in parens) appended to Text of Selected Node
Treeview ... Reacting to DragOver in a Treeview
Treeview ... Reacting to Drag and Drop
Treeview ... Repositioning Cursor to the Top of the Treeview



Note to Webmaster