|
-
September 7th, 2010, 11:52 AM
#1
for each & treeview-nodes
Hi,
I have a treeView control, to which i add treenodes at runtime.
How can i implement a for each loop as in
for each (TreeNode^ a in treeVie1->subnode....){
....
}
if "subnode" doesnt exist when compiling the program?
-
September 7th, 2010, 12:30 PM
#2
Re: for each & treeview-nodes
Errr.... What? Did you mean to ask this in a C# forum?
-
September 7th, 2010, 12:50 PM
#3
Re: for each & treeview-nodes
yeah...
-
September 7th, 2010, 09:56 PM
#4
Re: for each & treeview-nodes
No, the TreeView class doesn't have a subnodes member. But it has a Nodes property that is of type TreeNodeCollection ^. Unfortunately, you can't iterate over the nodes therein using a plain for each. Instead, you have to use the enumerator returned by its method GetEnumerator(). Of course, you'll have to do that in a recursive manner to get every single node contained in the TreeView.
I haven't used that myself yet, so I can't give you much more that these pointers to the MSDN docs for now. I hope it will help you, though.
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
|