Maybe it's just me.. But for the life of me, I cannot find how to add a LeftImage to a child node.
I'm adding a child node thru aNode.Nodes.Add(), but can seem to find where to assign an image.
Thanks.
hi,
I am not very sure weather i have got ur question correctly but it may help u ...
ChildNode.LeftImages.Add(Image)
Fordisplaying the Image in Cells of the node u can add the image
Cell.Appearance.Image = Image.
regards,
ravi
Thanks for info, I know what your describing, but that doesn't work.
Using a DataSet with a DataRelation for your data.
Create an UltraTreeNode (UltraTreeNode aNode)
While in a foreach()
Add the parent node with : aNode= tree.Nodes.Add(....);
While in a secondary foreach(datarow with getchildrows)
add the child nodes using aNode.Nodes.Add(key, display value);
I don't see anything like; aNode.Nodes.LeftImages.Add(image); that will add a leftimage to the child node.
I CAN access aNode.LeftImages.Add(image), but this sets the Node Image on the PARENT, not the child...
Hi,
U can achive this in following ways..
1) Instead of using the aNode.Nodes.Add(key, display value); Create the node first, Add the Left Images to the newly created node and the Add the newly Created Node to the parentNode.
UltraTreeNode ChildNode = new UltraTreeNode(Key, "Text");
ChildNode.LeftImages.Add(Image);
aNode.Nodes.Add(ChildNode );
2. You can retrive the ChildNode by key from the Ultratree, then assign the imgaes to the referance object.
Hope this will resolve ur issue.
ravi.
You can't use the Key property of the node, you have to get it from the data in the row. You can probably do something like node.Cells["Key"].Value, assuming that the ColumnSet is set up to display the key value or at least create a column for it. If not, then you can still get the key, but you have to get it from the data, rather than the node. The node exposes a ListObject property which will return you the underlying data object from the data source, so you can access any data you need from there.
Ok.. I went back and changed my bind to use the SetDataBinding methods and by reordering my Select statement in my SQL SP, I can see what I want displayed and can use the InitializeDataNode methods to customize each node level..
Now, last question... Where are my keys??? I can't open my data windows without knowing my selected node key... The bind does not set them, I can't find anything to define them....
I stand corrrected.. I just went back and tried to set the tree's DataSource at runtime with a relational dataset...
But, I can't use what it does..
It basically gives the a treeview of my datarelation, but only shows the Key Values, not the Actual Names of the Client and Contacts..
I assume I need to set somehow in InitializeDataNode but don't know how to do it...
Also, I've noticed that if I dbl click the expansion indicator, my dblClick event fires (makes sense), which opens a detail window. Is there any property to set so that if the indicator is dblclicked, I can catch it and NOT open the data window.
Mike,
I agree that binding the tree to a data source is much more efficient, however I've never gotten anything to display when I've tried this design.
I'm binding a relational dataset that being returned from our 2nd tier to the tree and nothing ever displays.
For example.. this.treeTest.DataSource = clientList.GetClientsContacts();
Where the GetClientsContacts method returns the relational dataset to bind to the grid.
If I'm doing something wrong please let me know as the Infrag documention is not very good in giving examples about this.
I had to get this working for a client so that's why I used the looping.
Mark
aNode.Nodes is a collection of nodes, not a single node. So that's why it doesn't have a LeftImages property. To get the LeftImages, you would have to reference a node in the collection like aNode.Nodes[0].LeftImages.
If you are binding the tree to a data source, then another way to do this that is more efficient than looping. You can use the InitializeDataNode event. This event passes you the node being created from the data source. This is more efficient because these nodes are created lazily, so you won't be forcing the tree to create nodes that might never be needed.