|
-
Mar 17th, 2003, 04:57 AM
#1
Thread Starter
Addicted Member
Looping all items in a Treeview control
Hi,
I am relatively new to .NET and am struggling a little with some of the changes from VB6. I programmed version 6 for some years now.
I want to loop through all items in a treeview control. I have found that the nodes collection exists but it doesn't have a count property. Instead, I have found "system.collections.ienumerator" which is what I am supposed to use now, but I can't find any legible help. Can somebody show me a little code that will do what I am after? I would be most grateful.
Thanks in advance,
DJ
-
Mar 19th, 2003, 12:32 AM
#2
PowerPoster
I'm not at my dev box right now, but here is a sample recursive routine that would traverse the treeview:
Code:
private void TraverseTreeView(TreeNode node)
{
for(int i = 0; i < node.Nodes.Count; i++)
{
listBox2.Items.Add(node.Nodes[i].Text);
TraverseTreeView(node.Nodes[i]);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|