Solved

VB.net Add nodes to TreeView node with certain key

Posted on 2012-03-13
3
1,075 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
3 Comments
 
LVL 85

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL syntax in VB.net 5 41
VB.NET 2008 - SQL Timeout 9 26
Convert datetime to time string 10 22
Iteration Help (Asp.net VB) 5 13
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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