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