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

How to add both image and text in one column of RadGrid View?

1 Answer 479 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dipankar
Top achievements
Rank 1
Dipankar asked on 19 Nov 2012, 01:45 PM
I have added one RadGridView in Telerik(C#) Winform. I need a column with both text and image data in it. But RadGridView only have header image option. Kindly help me out.....

1 Answer, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 19 Nov 2012, 02:30 PM
Hello,

Just handle the CellFormatting event, check for the column you require and pass the image you want to the cell, like so:
void grid_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.Column.Name == "SomeColumn")
    {
        var dataBoundObject = e.CellElement.RowInfo.DataBoundItem;
        e.CellElement.Image = dataBoundObject.Image;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.ImageProperty, ValueResetFlags.Local);
    }
}

You have to keep in mind that because the grid reuses cell (just the displayed cells are created and drawn), you will have to reset the custom properties you set on the cell.

Best Regards,
Emanuel Varga
WinForms MVP
Tags
GridView
Asked by
Dipankar
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Share this question
or