Treeview Index problem

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?
 
G

Guest

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top