Solved

vb.net Treeview from XML AfterSelect

Posted on 2014-01-23
2
351 Views
Last Modified: 2014-01-30
Hi,

I have an application I am building in Visual Express which contains a treeview that populates from XML. The XML looks something like this

<Town>
 <Street>
  <House>
    <Name>John's House</Name>
    <Doornumber>1</Doornumber>
    <Owner>John Smith</Owner>
    <HasPet>Yes</HasPet>
    <LikesGardening>No</LikesGardening>
   </House>
  <House>
    <Name>Jane's House</Name>
    <Doornumber>2</Doornumber>
    <Owner>Jane Jones</Owner>
    <HasPet>No</HasPet>
    <LikesGardening>Yes</LikesGardening>
   </House>
  </Street>
</Town>

Open in new window


The Treeview is coded to look like the following

+Town
  +Street
   - John's House
   - Jane's House

i.e. the treeview ends at the <House> node and displays the name of the <Name> node.

I want the AfterSelect sub to display the other leaf nodes in that <House> in various text fields.

At the moment what I am trying to do is translate the fullpath attribute of the selected node into the XML path, but I am sure there must be a better way to do this.

How would you do it?

Thanks

Mike
0
Comment
Question by:ubya308
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 39805147
I would think that you could get the child nodes for the selected node, and do the processing that you need.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39806176
Further to TheLearnedOne's comment, AfterSelect event passes you TreeviewEventArgs which you can use to get the list of all child nodes of the selected now

e.Node.Nodes

and loop through to get all the houses. You can determine if the selected node is a street node by checking the e.Node.Level property.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now