Click here to Skip to main content
15,913,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a TreeView populating from xml source,after loading the Treeview on selecting the values from the node the corresponding values should get bind inside the grid.
Posted
Updated 21-Jun-10 7:39am
v2

Start by reading the docs for the TreeView[^] and GridView[^] classes and learning how to adapt those examples to meet your own needs.

If you want a more specific answer then you'll need to post a more specific question.
 
Share this answer
 
Here is the basics;

C#
private void readAndWrite()
{
//Read a value from Treeview
int theNode = 1;
String theValue = treeView1.Nodes[theNode].Text;

//set a value in a DataGridView
int theRow = 10;
int theCol = 5;
dataGridView1.Rows[theRow].Cells[theCol].Value = theValue;
}
 
Share this answer
 
That's a much better question.

To show the data in the TreeView you can either use the XDocument[^] (or any of the other XML Parsing classes in .Net) to load the XML file, parse the node structure out and then create and add nodes to the TV. Alternatively it looks like .Net 4 has a DataBindings[^] property on Controls that may do the job for you.

The docs show you how to create and add nodes manually. Then you can handle the AfterSelect event to change what's shown elsewhere on your app. I really don't use grids that much so I can't help you with that one. Sorry :(
 
Share this answer
 
One thing you could do is use a BindingList. (See here: BindingList<(Of <(T>)>) Class[^])

What you would do is create the binding list to be set up with either a custom class or a pre-defined class that would contain your information.

Then, you would bind the datagridview to that list. For an example with the datagridview, see here: C# Tutorial - Binding a DataGridView to a Collection[^])

Then, when the selected item in the TreeView is changed, clear the binding list and add a new item to it. The datagridview will update with the changes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900