G
Guest
I'm trying to program a form with a treeview. I have just created a root
node in the control. Now I have called a routine to create a child node. As
I create these nodes I want to keep track of their indices in a data
structure. The code is roughly as follows:
(Assume the original root node is the selected node)
Dim tn As New TreeNode
tvAreas.SelectedNode.Nodes.Add(tn)
tvAreas.SelectedNode = tn
At this point I try to get the index of the selected node and it's always -1
I've tried both
i = tvAreas.SelectedNode.Index
and
i = tvAreas.Nodes.IndexOf(tvAreas.SelectedNode)
What's going on here?
node in the control. Now I have called a routine to create a child node. As
I create these nodes I want to keep track of their indices in a data
structure. The code is roughly as follows:
(Assume the original root node is the selected node)
Dim tn As New TreeNode
tvAreas.SelectedNode.Nodes.Add(tn)
tvAreas.SelectedNode = tn
At this point I try to get the index of the selected node and it's always -1
I've tried both
i = tvAreas.SelectedNode.Index
and
i = tvAreas.Nodes.IndexOf(tvAreas.SelectedNode)
What's going on here?