Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting Treeview Index

0 views
Skip to first unread message

Kelvin Bryant

unread,
Oct 22, 2003, 10:31:06 AM10/22/03
to
I have tried the following code to set the index for a
node. It seems to work when I use the root node index of
0. When I try a number greater than 0 I get an out of
range error. I made sure that the tree was expanded, as
well.

treeView1.Focus();
treeView1.SelectedNode = treeView1.Nodes[1];

Nicholas Paldino [.NET/C# MVP]

unread,
Oct 22, 2003, 10:47:27 AM10/22/03
to
Kelvin,

How many nodes are there under the root? I think that the Nodes that
are being exposed is the top level of nodes, and not all of the nodes in the
tree. If you have only one node at the root, then this would definitely
fail.

Hope this helps.


"Kelvin Bryant" <kelvin...@hotmail.com> wrote in message
news:0b3901c398a9$20c210b0$3101...@phx.gbl...

Michael A. Covington

unread,
Oct 22, 2003, 10:53:33 AM10/22/03
to

"Kelvin Bryant" <kelvin...@hotmail.com> wrote in message
news:0b3901c398a9$20c210b0$3101...@phx.gbl...

Note that treeView1.Nodes is only the list of nodes branching off the root;
not all the nodes in the entire tree.

treeView1.Nodes[1].Nodes is the list of nodes that branch off node 1, and so
forth. It's a recursive data structure.


anon...@discussions.microsoft.com

unread,
Oct 22, 2003, 5:45:58 PM10/22/03
to
Yes, you are on to something! My structure is as such:
Root Node
Parent Node 1
Child Node 1
Child Node 2
Child Node 3
Parent Node 2
Child Node 1
Child Node 2
Blah Blah Blah
>.
>
0 new messages