Hello,
I have a collection that contains children and those children can contain children etc. When i press on the rootnode to expand it works, when i click on the first childnode to expand it works etc. But when i press on the second childnode for example and i debug through the code (ColumnSetGenerated event) i see that the columnset doesnt contain any columns and it will display the children as Node4 for example instead of the columns.
Can someone help me with this problem?
Thank you.
Hmm found that property IsChaptered.
It works for that child, but when i try to expand the childs child, it doesnt do anything. When debugging is tells me that there is one child, but it isnt shown. neither the columnsetgenerated event is called anymore, maybe thats logical, but still dont know why it isnt shown then.
Btw in the meanwhile im trying to dont use a datasource anymore, im trying to build the columnsets and nodes in code.
Hey Mike,
I am not sure how that static method can help me, but maybe i have made a little bit progress.In the ColumnSetGenerated event i now check if the columnset contains columns, if not i loop through a list that contains the columns that need to be shown (The dynamic properties) and then for the hardcoded properties i check the type of the selectednode and then i retrieve the PropertyInfo.Those columns i load into the e.columnset.columns.add.But now my children properties are also being shown as column, how can i prevent this?
Mike Saltzman said:Maybe I misunderstood, but you said in your post above that there are not rows at the time you are binding the tree and that the nodes get added later in the BeforeExpand event. This is too late. The data structure is determined as soon as the parent node is loaded and displayed on the screen, so by the time the user tries to expand that node, the ColumnSet will already have been created - or failed to be created in this case.
But this still doesnt explain why the first node will work correcly, i suppose.
KevinKlein said:You say if the bindingmanager cannot find any (children) rows, it cannot get the columns.But there are children rows, but they are only show as node0, node1 etc.
Maybe I misunderstood, but you said in your post above that there are not rows at the time you are binding the tree and that the nodes get added later in the BeforeExpand event. This is too late. The data structure is determined as soon as the parent node is loaded and displayed on the screen, so by the time the user tries to expand that node, the ColumnSet will already have been created - or failed to be created in this case.
By the way... there's a static method on UltraTreeColumnSet where you can pass in a DataSource and a DataMember and it will return an auto-generated ColumnSet to you. So you could check the ColunnSets collection on your tree and see if one exists for the band and if not, create it.
I am not really sure i can follow you.You say if the bindingmanager cannot find any (children) rows, it cannot get the columns.But there are children rows, but they are only show as node0, node1 etc.Lets say i have a 2 rootnodes, the first one is named 'Host1' and the second one is named 'Host2'.When i expand the first rootnode everything works fine, and when i then expand the second rootnode is also works OK (It will show his children, with the correct columns). But lets say i first opened 'Host2' (and i know it will have 2 children), the childnodes will look like this: Node0 and Node1.Just to test it, i created a class 'CustomClass' which overrides from BindingList and implements IEditableObject and ICancelAddNew. But do i need to write some extra code in those implemented methods? I just said for example in the EndEdit method, this.EndEdit();
Thanks Mike for the help, appreciate it:)
KevinKlein said:Now i am using the beforeexpand event to fill the children belonging to a parent.
This is probably the problem. Depending on the DataSource you are using, the BindingManager in DotNet may need to have a row of data in order to determine the data structure at a particular level. If there are no rows, it can't get the columns and so the tree and the grid cannot, either.
What it will do in a case like this is try to create a new row and then cancel it. So if you are creating your own custom data source, you have to implement either IEditableObject or ICancelAddNew in order to allow the BindingManager to create a row and then cancel it.
Another option is, of course, to simply create the ColumnSets yourself.