This is a migrated thread and some comments may be shown as answers.

how can I add an bitmap from Resources to Grid Column

1 Answer 414 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 20 Aug 2020, 12:58 PM

 

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);

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 20 Aug 2020, 01:42 PM

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).

Tags
GridView
Asked by
Andreas
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or