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?
My apologies, ignore the previous append. I was under the impression that
there was a master index for all nodes in a treeview, not just relative
indices for each node. (Of course, if this assumption is also wrong, please
feel free to correct me.)
> 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
[quoted text clipped - 15 lines]
>
> What's going on here?