Solved

VB.net Add nodes to TreeView node with certain key

Posted on 2012-03-13
3
1,122 Views
Last Modified: 2012-03-13
Hi

I have been given a task to load a TreeView in VB.net from three arrays

arrKey, arrDescription, arrParentKey

For each array index I have to add a node with key arrKey and text arrDescription under the node that has a parent node with key arrParentKey

What code would I use?

Thanks
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 37715601
That would be pretty similar to the answer I gave in your other PAQ:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_27625079.html#a37702224
0
 
LVL 17

Assisted Solution

by:nepaluz
nepaluz earned 250 total points
ID: 37715718
try something like this
        Dim Result = From x In xStringH.Descendants() Where Not String.IsNullOrEmpty(x.@key)
                    Let xNod = New TreeNode Select New With {.xKey = x.@key,
                                     .xParent = x.Name.LocalName,
                                     .xDescription = x...<DESCRIPTION>.Value}
        Dim xTree As New TreeView

        For Each x In Result
            Dim xNod As TreeNode = New TreeNode() With {.Name = x.xKey, .Text = x.xKey}
            xNod.Nodes.AddRange({New TreeNode With {.Name = x.xParent, .Text = x.xParent}, New TreeNode With {.Name = x.xDescription, .Text = x.xDescription}})
            xTree.Nodes.Add(xNod)
        Next

Open in new window

to get
result
0
 

Author Closing Comment

by:murbro
ID: 37716843
thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question