Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
Having trouble with putting an image in a cell
posted

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?

Parents
No Data
Reply
  • 170
    posted

    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.

Children