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

2 posts, 1 answers
  1. Dipankar
    Dipankar avatar
    2 posts
    Member since:
    Sep 2012

    Posted 19 Nov 2012 Link to this post

    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.....
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top