Hi,
I have a problem relating to the displayed node text associated with a databound treeview control with a standard viewstyle. In this scenario, the underlying business object ( bound to the treeview via a bindingsource ) has a number of child collections associated with it. When the tree creates its node hierarchy ( and in turn generates its column sets ) it uses the property names of the underlying collections for the displayed node text. As this isn't very user friendly I want to be able to override it and change it for something more helpful to the user. For all subsequent child nodes associated with each collection, its easy to select the required field via the column set editor, but for the collection properties themselves I can't seem to be able to override the default behaviour.
Any suggestions / advice would be most welcome!
Many thanks,
Nick
Handle ColumnSetGenerated and set the UltraTreeColumnSet.NodeTextColumn property to reference the column that you want to provide the node text.
But I can't Brian as the collection property is itself a column within the columnset.
For everything else then I agree that I could either handle the ColumnSetGenerated event, or set the appropriate node text column within the columnset designer at design time.
I have created the following support ticket for you: CAS-52275-8X3RQL . And if you are able to provide a sample where this behavior is reproducible, I will research the different options for your scenario.
Thank you.
Regards,
Stefaniya
It sounds like you are referring to the Band Nodes which separate sibling bands. To change the text on those, what you can do is handle the InitializeDataNode event. Check for e.Node.IsBandNode and you can set the Text property on the node to whatever you want. You can determine the band that the node is associated with by using e.Node.BandName
Ah, that's why you have so many points Mike! - you were 100% correct in your assumption and your suggestion as to how to fix my problem. Many thanks.
There is another related issue that you may be able to help with. The tree is databound to a normal windows bindingsource. This in turn is populated from a custom business object, however in this instance the BO has a child collection list. Think of it as a customer BO which in turn contains a list of customer contacts. To facilitate editing of the data, there is a 2nd bindingsource on the form ( bindingSourceContacts ) which has its datasource set to the first bindingsource ( bindingSourceCustomer ) and its DataMember set to the customers ContactsCollection. The tree is set to SyncWithCurrencyManager, however moving around the contacts nodes does not move the child bindingsource. This probably makes sense as the tree is not bound to the child bindingsource, but is there any way that the tree can maintain currency with both the parent and the child bindingsources ?
Thanks,
Hi Nick,
There's no way that a single tree can stay in synch with two different data sources. You could bind two different controls and probably get the second tree to stay in synch with the first, but even this can be pretty confusing even in the simple case of using a single data source like a DataSet. When you start using two different BindingSource objects, the complexity can only increase.
Your best best would be to manually set the ActiveNode in the tree.
That would make sense Mike. I'll probably trap the tree's AfterActivate event and then use this to move the child binding source positions manually so that they stay in sync. There is also a grid associated with the child binding source so I will also trap the AfterRowActivate event on that to set the tree's active node as required.