Results 1 to 3 of 3

Thread: [RESOLVED] Treeview node > convert value > add node treev2

  1. #1

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Resolved [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.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Treeview node > convert value > add node treev2

    Quote Originally Posted by Radjesh Klauke View Post
    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:
    1. 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Treeview node > convert value > add node treev2

    Ah. Thanks


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width