Hello,
I have an UltraTree which has a view style of OutlookExpress.
I dynamically create the tree and add the nodes to the first UltraTreeNodeColumn I have. That way I have the tree positioned in the left most column of the Grid. This column is defined as follows:
UltraTreeNodeColumn TreeCol = new UltraTreeNodeColumn(); TreeCol = new UltraTreeNodeColumn(); TreeCol.Key = "Tree"; TreeCol.Text = "Tree"; TreeCol.MaxLength = 100; TreeCol.NullText = "NULL"; TreeCol.AutoSizeMode = Infragistics.Win.UltraWinTree.ColumnAutoSizeMode.VisibleNodes; TreeCol.AllowSorting = DefaultableBoolean.True; TreeCol.DataType = typeof(string); ultratree1.ColumnSettings.RootColumnSet.Columns.Add(TreeCol);
As can be seen, the type of data this column receives is a string, i.e. the node's name.
My problem is that I am having trouble displaying an image / icon on the left hand side of the node's name. This feature was possible when the UltraTree was defined as standard for example and then the code below worked:
node.Override.NodeAppearance.Image = _ImageList.Images["img"];
Now that my tree has an OutlookExpress look-and-feel the icons I initially defined do not appear any longer even though the code executes correctly.
What's the best way to add icons to the nodes in the UltraTreeNodeColum?
Thanks.
Yes; you can still add an unbound column when you are bound to a data source. Alternatively, you could add (for example) a DataColumn to the same DataTable, of type Image, having the images in the table data, and the tree will display the images the same way as when the unbound column is used.
Juscher said:Thank you, that's exactly the behaviour I was looking for: an image to the left of each node label in the tree column. Of course if I move the tree, the icons have to move with the labels !
My point here is that, unlike with the standard ViewStyle where the NodeAppearance.Image is always displayed between the expansion indicator and the node's text, in this scenario the image is contained within the cell, and if you move the column (not talking about moving the control), the image moves along with it, and won't be the leftmost element anymore.
Brian Fallon"]Assuming you are going with the unbound column solution, you add the column in response to the ColumnSetGenerated event, and assign the actual value for each node in response to the InitializeDataNode event:
Cool, but what about bound solution, when I have a datasource - what to do. Would your code still work ?
Thank you, that's exactly the behaviour I was looking for: an image to the left of each node label in the tree column. Of course if I move the tree, the icons have to move with the labels !
I think that answers the original question of this thread : "displaying an image / icon on the left hand side of the node's name".
Just to clarify, that will display the image inside that cell, and if that column is moved, the cell will move along with it.