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.
Hi Mike,
I was interested in that as well and tried it yesterday. When I passed only a simple BindingList<T> to the UltraTree it worked well. But then I tried it with a hierarchical list and all I saw was the root nodes collection. Probably I have some mistake in my data structure. Can you please have a look and tell me what I am doing wrong?
Here is the data structure:
public class TreeListItem{ private string _name; private BindingList<TreeListSubItem> _treeListSubItems = new BindingList<TreeListSubItem>();
public string Name { get { return _name; } set { _name = value; } }
public class TreeListSubItem{ private string _name;
public string Name { get { return _name; } set { _name = value; } }}
I populated the list and bound it to the datasource like this:
treeListBindingSource.DataSource = TreeList;}
The treeListBindingSource is of type System.Windows.Forms.BindingSource. It's not an Infragistics-BindingSource. Might that be the problem or did I make a mistake with the data structure definition?
Thanks in advance and best regards,
Gerald
I tried copying your code into a new project and I had to make a small change to the InitLayoutTree2 method since the code you have here never defines the TreeList variable.
private void InitLayoutTree2() { TreeList treeList = new TreeList(); TreeListItem item = new TreeListItem("Overview Window"); treeList.Add(item); item.TreeListSubItems.Add(new TreeListSubItem("Overview 1")); item.TreeListSubItems.Add(new TreeListSubItem("Overview 2")); item.TreeListSubItems.Add(new TreeListSubItem("Overview 3")); treeListBindingSource.DataSource = treeList; }
But once I do that, it works fine for me. I see one parent and three child nodes in the tree. I'm attaching my sample (with your code in it) here. If this sample doesn't work for you, then my guess is you have an old version of the control and you need to get the latest hot fix.
I am very new to Infragistics and I have tried to to bind my data structure List<T> to WinTree control. WinTree does not display the hierarchical structure of my data.
My classes hierarchies are:
BaseConfiguration class has public Property to Set/Get Name as string
ConfigurationAttribute class has public Property to Set/Get Name as string and Value as string
ConfigurationElement class is a sub class of BaseConfiguration. It has public Property to Get List<ConfigurationAttribute> AttributeCollection
ConfigurationSection class is a subclass of BaseConfiguration. It has public Property to Get List<ConfigurationElement> GetConfigSectionCollection
ConfigurationSection
config = new ConfigurationSection();
config = xmlParser.Parse(readerType); // populate hierarchy data structure
UltraTree.DataSource = config.GetConfigSectionCollection;
This seems like it should work, as long as the properties you are referring to here are properties (not just members) and that they are public.
Are you creating any ColumnSets in the tree yourself? Or are you just leaving the tree to it's default settings and letting it create the ColumnSets automatically?
What exactly are you seeing in the tree? Which columns do you get?
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