I have an UltraTree
I also have a BindingSource that has a List<ClassA> as it's Data source. Plan jane stuff
I call set DataBinding
tree.SetDataBinding(bsBindingSource, null);
The list has classes with collections but their all empty.
So the tree populates fine( 1 level )
On the AfterActivate event I then add an item to on of the lists' class collections ( ClassA.MyCollection.Add())
I can bsBindingSource.ResetBindings()
But the Tree View Doesnt show a 2nd level tree item.
I can add one manually, but how do I get the tree view to see the second level?
Hi,
The tree gets the data structure from the BindingManager in DotNet. My guess is that if you are using a List<T>, then the BindingManager cannot get the structure from the child band without having an actual row to work with.
Normally, what it will try to do in a case like this is add a row and then cancel that row using the IEditableObject interface. But I don't think List can support that, you would have to use BindingList and implement IEditableObject on your list items. Implementing ICancelAddNew on the BindingList instead of using IEditableObject on the items might also work, but I haven't actually tried that.
yeah I'm using BindingList.
I just assumed that If I had 5 objects that had emtpy collections and I populated a collection in object 1
I can rebind the BindingSource to the control and it would find the collection.
And I see theres column sets I can create.
Is there a way to create a columns set that says
level1 look for propertyA
level2 look for propertyB in Collection1 of the object
Just curious.
Nick
Hi Nick,
Yes, you could create the column sets manually in code. You just have to make sure that the ColumnSet key is the same as the key of the band in the data. In the case of a List, the band key will be the name of the property that property that provides the child list. The root band probably has no key - but that one is working anyway, so you don't need to worry about it.
Basically, what you do is add a column to the parent band with the key of the property the represents the child list. I am assuming it's not already there. Just make sure to set the IsChaptered property on the column to true. That tells the tree to display the property as a child list, rather than as a normal column in the parent band.
Thanks a lot for the help.
I'm clueless on how to create a column set, but I can google it.
I'll try it this weekend...have a good weekend.