how can I add an bitmap from Resources to Grid Column

2 posts, 0 answers
  1. Andreas
    Andreas avatar
    6 posts
    Member since:
    Oct 2017

    Posted 20 Aug Link to this post

     

    I'd like to add and show an Bitmap from Resources to Grid Column. But it doesn't work.

    Is there any very simple example?

    Gridview.Rows[count - 1].Cells[header].Value = new Bitmap(Resources.test);

  2. Todor Vyagov
    Admin
    Todor Vyagov avatar
    44 posts

    Posted 20 Aug Link to this post

    Hi, Andreas,

    To set an image to a cell you can use the CellFormatting event of RadGridView.

    void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
    {
        if (e.RowIndex == count - 1 && e.ColumnIndex == header)
        {
            e.CellElement.Image = new Bitmap(Resources.test);
        }
        else
        {
            e.CellElement.ResetValue(LightVisualElement.ImageProperty, Telerik.WinControls.ValueResetFlags.Local);
        }
    }

    For more information about formatting cells visit our help article: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells

    If you have a whole column with images I recommend using an image column: https://docs.telerik.com/devtools/winforms/controls/gridview/columns/column-types/gridviewimagecolumn

    Additionally, if you want to set header cells image, refer to the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/styling-and-appearance/images

    Let me know if I can assist you further.

    Regards,
    Todor Vyagov
    Progress Telerik

    Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Back to Top