Solved

VB.net Add nodes to TreeView node with certain key

Posted on 2012-03-13
3
1,158 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:Murray Brown
[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:Murray Brown
ID: 37716843
thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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