I'm getting rather frustrated trying to display an image in a cell.
First, I'm adding an extra column maually to contain the image cell, like this:
Infragistics.Win.UltraWinGrid.UltraGridColumn iconColumn= grid.DisplayLayout.Bands[0].Columns.Add("IconColumn"); grid.DisplayLayout.Bands[0].Columns["IconColumn"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Image;grid.DisplayLayout.Bands[0].Columns["IconColumn"].Hidden = false;grid.DisplayLayout.Bands[0].Columns["IconColumn"].Header.VisiblePosition = 0;grid.DisplayLayout.Bands[0].Columns["IconColumn"].Header.Caption = "Icon";
Next, in the InitializeRow event, I say:
if (Convert.ToBoolean(e.Row.Cells["RadioExists"].Value.ToString())== true) { e.Row.Cells["IconColumn"].Appearance.BackColor = System.Drawing.Color.Black; e.Row.Cells["IconColumn"].Appearance.Image = System.Drawing.Image.FromFile(@"FilePath");
}
it colors the cell fine, but doesn't show my image. I'm sure the image exists and it is loaded because I've checked the Appearance.Image after it runs and there is a value in there. What am I doing wrong?
I always set the value of the column to a System.Drawing.Image .. i don't think its the appearance that you're looking for.
e.Row.Cells["Key"].Value = image
also, I'm not sure how much IO overhead there is in doing Image.FromFile for every row but you might consider pre-loading your images in the form's Load or something and just making the assignment when the rowInit fires.
I've actually got an ImageList which contains all the images I need, but I changed it in the code example to try and simplify it.
I changed the line to be:
e.Row.Cells["IconColumn"].Value = imageList.Images["Icon"];
Now I get an error reading "Object must implement IConvertible". Any thoughts?