Is there a way to bind the Win Tree to a List?
Simply doing
WinTree.DataSource = List
Results in an empty tree.
Never mind. Forgot to give public properties to the custom object.
New Quesion in the same area.
I have a custom object that has two properties; Key and Name
I want to bind a list of these objects to a WinTree
I want the node key to equal the Key property and the Text equal to the Name property.
Is here a way to do this?
It uses the value provided by the column referenced by the UltraTreeColumnSet's NodeTextColumn property. When this property is not explicitly set, it uses the first column in the ColumnSet. In the case where you are binding to a .NET object, I have noticed that it seems to use the first property defined in the class; presumably when the code file is parsed the property descriptors are created in the same order that the public properties appear in the class. So to answer the question: set the NodeTextColumn property to the name of the property you want the node's text to reflect.
Setting the key proved to be easy. However, i'm having difficulties setting the name. If i look at the node text after i do Nodes(0).Text = "test" the node text value still says oldText. Is there a way to specify the node text?
Back to the original question. How does the tree determine what which obeject property to use for node text. I've noticed that properties named "Key" or "Name" are more likely to be selected to become the Node.Text. However, there seems to be no real logic as to what property is picked. At this point i've been forced to changed all my properties to Set and Get functions. Is there a way to bind the Node.Text to an object property?
You can handle the InitializeDataNode event and set the Key property on the UltraTreeNode reference returned from the Node property of the event arguments. Note that keys must be unique across all Nodes collections; you can use the DataKey property if the keys you are assigning are not unique.