Hello,
I'm trying to show an image on an cell. I've created a new column and changed the DataType. and in the InitializeRow i'm saying which photo should appear, but this don´t work. The column appears empty. Here´s my code:
InitializeLayout... gData.DisplayLayout.Bands[0].Columns.Add("New"); UltraGridColumn col = gData.DisplayLayout.Bands[0].Columns["New"]; col.DataType = typeof(Bitmap); col.Header.Caption = CM.GetString("New"); col.Header.VisiblePosition = 1;...
InitializeRow... if ((bool)e.Row.Cells["ReadByAssignedTo"].Value) img2 = new Bitmap(Properties.Resources.newTask); else
img2 = new Bitmap(Properties.Resources.oldTask);
e.Row.Cells["New"].Value = img2; //e.Row.Cells["New"].Appearance.ImageBackground = img2;...
Can you please tell me what's wrong with this code?
Thanks
Just to clear up a little confusion here... there are two different ways to put an image in a cell.
If you just want a cell to display an image from the data and nothing else, then the way you have here in the original post is correct. You set the data type of the column to Bitmap and then assign an image to the Value of the cell. If that's not working, then my only guess is that you are using a really old version of the grid that doesn't automatically detect Bitmap and display it as an image. If that's the case, all you have to do is set the Style on the column to Image.
the other way, using an Appearance, will only work for cells of other types. It will not work for a picture-style cell, because the image on the Appearance is intended to display along with the other data in the cell, not by itself. And it doesn't make any sense to have a cell whose value is an image and then to display an additional image in that cell along with the image from the cell's value.