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
410
Displaying image on an cell
posted

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

Parents
No Data
Reply
  • 20872
    Offline posted

    Hello,

    I have tried the following code in the InitializeRow event of the UltraGrid and it work as expected.

     if ((bool)e.Row.Cells["New"].Value)
                {
                  img2 = Image.FromFile("First.jpg");
                }
                else
                {
                   img2  = Image.FromFile("Second.jpg");
                }

    //You are able to use this one to set the Background Image
    e.Row.Cells["Image"].Appearance.ImageBackground = img2;

    //Or you the following one to show your desired image as a value

    e.Row.Cells["Image"].Value = img2; 

    So if your column is empty are you hooking you InitializeRow event to the UltraGrid?

    Please try this at your end and let me know if you have any further questions.

    Sincerely,

    Danko Valkov

    Developer Support Engineer

    Infragistics, Inc.

     

     

Children