Hello,
I have a problem.
I have created a custom class with a method that retrieves some data and puts it in a list, that list is returned and i have assigned this list as the datasource for the ultrawintree.
In my custom class i have created an Image property, which returns a default image. It is needed that the ultrawintree shows this column as an image. But instead of showing the image it shows "System.Drawing.Image".
I have tried to set the datatype of the column to typeof image, but no luck.
Can somebody help me with this?
Don't set the .Value of that cell but instead use the image property of the cell.
Example:
node.Cells[SomeKey].Appearance.Image = imageList2.Images["SomeImage"];
hope that helps
Hmm, i dont fully understand it.
i have a public class (MyClass)
in that class i have set some public properties
public Image DataType {get;set;}
public string Name {get;set;}
public int ID {get;set;}
I have a list with the type of this class and this list is bound to my datasource. So the columns that it will show are these 3 properties shown above. Everything is being shown fine, but the Image property isnt.
Suppose that i have another class MyClass2, this class also contains a property Datatype of type image, i want a different image for items of this class. btw MyClass contains a also a list of type MyClass2, so this can be seen as a childrenslist.
Isnt it possible that that ultratree uses the imagevalue that i have set for each class in the column DataType?
i don't know - i've never used it with a connected DataSet. I fill the nodes/cells "by hand" in a "foreach"-loop for example. This way i have more control about what happens, what value is put into the cell and how it is filled.
I cannot see a DataType "Image" for a cell so i would doubt that it will work like you hope.
I think it should be possible for you to get an event or callback or something whenever a new node is added or whenever a special cell is about to be filled with data. Once you know how to get this event, you may handle just the filling for that image-cell by hand to set the Cell-Image like i wrote you (of course not out of an ImageList but out of your own class).
To get the events, maybe a creationFilter could work. I'm not an infragisticGuru here but look at this (i needed an event to know when a node is getting visible because i have to load an image. I only like to load images for nodes that are visible and not for 10.000 nodes that are in that treeView. So i did this). Debug the "if (parent is ..." part to see which types are possible. Somhow a "cell" or something should appear:
Somewhere set the Filter like:
tree.CreationFilter = new TreeOwnerDraw();
public class TreeOwnerDraw : Infragistics.Win.IUIElementCreationFilter { public void AfterCreateChildElements(Infragistics.Win.UIElement parent) { //Nothing in here. } public bool BeforeCreateChildElements(Infragistics.Win.UIElement parent) { //Declare some variables TreeNodeUIElement nodeUIElement; if (parent is TreeNodeUIElement) { nodeUIElement = (TreeNodeUIElement)parent; UltraTreeNode node = nodeUIElement.Node; if ((node != null) && (node.Tag != null)) { //do something with the node that is about to be created } } //Return false to let the grid know we did not handle the event. return false; } }
This is even a better solution then i already had. I've got it to work with the columnset[column].EditorComponent property. I created an picturebox and set it to the editorcomponent of the datatype column. But your solution doesnt even require that. So thank you, it works:)
There's a much easier way.
Assuming you are not creating the ColumnSets yourself and are just letting the tree generate them from the data, what you do is this:
private void ultraTree1_ColumnSetGenerated(object sender, Infragistics.Win.UltraWinTree.ColumnSetGeneratedEventArgs e) { if (e.ColumnSet.Key == "key of the band that has the image column") e.ColumnSet.Columns["my Image Column"].Editor = new EmbeddableImageRenderer(); }
Maybe thats the best solution, just add the nodes by hand. I will give it a try and let you know.
Maybe there are some other people that know how to deal with binding a list to the datasource that contains an image.