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.
Finally I found out how to do it exactly as I want it to look like. It was just not easy to find the right attribute to set :
ultraTree.Nodes[parentKey].Cells[key].Appearance.Image = image;
Now I have an icon on the left ot each node of the tree in my OutlookExpress view.
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:
private void ultraTree1_ColumnSetGenerated(object sender, ColumnSetGeneratedEventArgs e){ TreeColumnsCollection columns = e.ColumnSet.Columns; UltraTreeNodeColumn imageColumn = columns.Add( "Image" ); imageColumn.DataType = typeof(System.Drawing.Image);}
private void ultraTree1_InitializeDataNode(object sender, InitializeDataNodeEventArgs e){ if ( e.Reinitialize == false ) { Image image = Image.FromFile( @"C:\Wherever\whatever.bmp"); e.Node.SetCellValue( e.Node.DataColumnSetResolved.Columns["Image"], image ); }}
It's not impossible, but the image needs to be in a column. This is how it works in OutlookExpress, so the tree mimics this behavior.
Hello !
I found this post as I was looking for how to add images to the left of each tree node in the OutlookExpress style....
Is it really impossible ? Too bad, it would have been great, this feature is really missing, because the OutlookExpress view is very practical for editing attributes of the tree nodes !
It's hard to provide a sample without knowing more about what you aredoing. But there's really not much to it. It looks like you are creating your ColumnSet in code and adding columns to it. So all you need to do is add one more column. Set the DataType on the column to an image type, like BitMap, for examine. Then when you add the nodes to the tree, put a BitMap into the value of that cell, just like you would populate the value of any other cell.