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
650
How to display an Image in a Cell
posted

How do I display an image in a cell?

I have done this previously but its not working in 2009.1 Grid.

I have tried the Image and ImageBackground but neither appear. The image I am setting it to does exist and contain data.

Here is the code:

 

private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
        {

            try
            {

        
                e.Row.Cells["STOCK_IMAGE"].Appearance.ImageBackground = Image.FromFile("C:\\jon2.jpg");
                e.Row.Cells["STOCK_IMAGE"].Appearance.ImageBackgroundStyle = Infragistics.Win.ImageBackgroundStyle.Centered;
                e.Row.Cells["STOCK_IMAGE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Image;
            }
            catch
            {


            }


        }

Parents
  • 469350
    Offline posted

    Are you trying to display an image in the cell along with the text already in the cell? Or do you just want the entire cell to display the image?

    The problem with the code you have here is that you are doing half of each.

    If you want the image to show up along with the text, just set the Appearance.Image on the cell. Do not set the Style to Image.

    If you want the whole cell to simply be an image without any text and without any editing, then you should set the Style of the cell to Image and set the Value of the cell to the image you want. Also... if the whole column is displaying images, it would be more efficient to set the style on the Column, rather than on each individual cell.

Reply Children