Hi All,

Say I have two list box listBox1 and listBox2... i have some data loaded in listBox1 which is taken from XML file listBox1Data.xml... and for ex it contains A,B,C,D etc... and listBox2 i need to load data from another XML file which contains data like for A->a,b,c etc.. B->b,c,d.. etc.. it means if user selects A from listBox1 it needs to load all the subelements of main element 'A' from the listBox2.xml... can any one pls help in accompalising this in C#?

Thanks,
Pradeep

Take a look at the dataset class. It has load/save xml methods that will automatically create a datatable containing the data in your XML document.

you can then use standard databinding if you are they type to use it, or you could navigate the datatable and select all the rows(sub elements) of each column(top elements) and add them to the listbox.

Here is a partial example of the concept, this isn't too advanced so you'll probably get a lot out of the experience of figuring it out. In this example I load the data from 1 XML file, and populate listbox 1 with toplevel xml as tables and listbox 2 with child elements of each as columns, the xml is loaded from the textbox on the form.

Give it a shot and adapt it to your purpose. Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.