|
-
May 9th, 2012, 04:37 AM
#1
Thread Starter
PowerPoster
[RESOLVED] Treeview node > convert value > add node treev2
Ola,
Not sure how to explain my question but here I go:
I have a Treeview with nodes.
example:
- 25
- 50
- 75
- 85
After a click of a button I want to do a calculation with all the nodes and add the result in a new treeview. There are no child-nodes.
How do I "loop" through the nodes, add, for example, 10 to the values and add each value/result to a new node in a second treeview?
I hope I made myself clear. If not, please ask. Really need this.
-
May 9th, 2012, 04:58 AM
#2
Re: Treeview node > convert value > add node treev2
 Originally Posted by Radjesh Klauke
How do I "loop" through the nodes
Pretty much exactly as you said: you loop through the Nodes. Nodes is a collection so you loop through it like you do any other collection:
vb.net Code:
For Each node As TreeNode In myTreeView.Nodes
You use 'node' inside the loop in whatever way is appropriate, e.g. get its Text, convert that to a number, add 10 to it, create a new TreeNode with that result as its Text and add that to another TreeView.
That said, I would tend to create all the additional nodes first and then use AddRange to add then to the Nodes collection of the second TreeView. It's always preferable to use AddRange to add multiple items to a collection if possible, especially if those items will be displayed in a UI.
-
May 9th, 2012, 05:15 AM
#3
Thread Starter
PowerPoster
Re: Treeview node > convert value > add node treev2
Ah. Thanks
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
|