i have object from class like this :
class student
{
private int st_ID;
private string name ;
private material[ mt;
}
class material
private int mt_ID;
private mark[ mk;
class mark
private int mk_ID;
now i recive object from student like this :
student [ ] std = new student[ ] { };
what i need to disblay in tree :
1- in first level the student name
2-in second level the material
3 in thired level the mark
remark : may be the student have mark may be not and may be have material and my be not
If you bind the tree to a List or BindingList of Student objects, then all you would have to do is add public properties that expose Lists or BindingList of the child objects (Marks and Materials).
thank you for replay ,but i am not undarstand can you explan the solution with example .
I don't have a sample of this, but the way data binding works is that the tree can bind to any object which implements IList or IBindingList.
If you are using Visual Studio 2005 or higher, then you can use the generic List<> or BindingList<> class.
So what you could do in this case is create a new BindingList<Student> class and add the student objects to the list. Use the list as the DataSource for your tree. Any columns you want to show up in the tree are represente by public properties of the Student class. If you want a property of the Student class to display as a list instead of a single cell value, then that property needs to return a list, so once again, you would use a BindingList<> type.
Thank a million. There was nothing proprietary in the code. I feel better when my code is not floating around.
I have removed the attached sample for you.
In the future, if you are concerned about posting proprietary information, we can arrange for you to send your sample directly through developer support. But generally speaking, it's better not to include anything proprietary in a sample. :)
Thanks. I now understand.
How can I remove my previous post with the attached project?
Hi Jean-Claude,
Thanks for the sample.
I ran your sample, and I am getting the same results you describe. There's a tree with a single node and when I expand that node, there are no child nodes.
The first thing I did was put a WinGrid on the form and bind it to the same data source and I get the same results: a single row with no child rows.
So I look a look at the DataSource you are assigning to the Tree, which is the baseConfigList variable which is a List<BaseConfiguration>. Since you are binding to a list of the Base type, only the properties of the base type will be exposed by the BindingManager in DotNet.
The tree, the grid, or any other bound control has no control over this. This is the way DataBinding in DotNet works.
I thought you were binding to the derived types, which is why I was confused about why this was not working.
I have attached the zip file.
Jean-Claude