How to change the header cell back color in radgridview?

2 posts, 0 answers
  1. tsz wai
    tsz wai avatar
    1 posts
    Member since:
    Jan 2015

    Posted 19 Jan 2015 Link to this post

    I want to set back color in the header cell, if  column is readonly, the header cell back color is green, else red.

    I found nothing method in GridViewColumn about set style.
  2. Todor Vyagov
    Todor Vyagov avatar
    31 posts

    Posted 20 Jan 2015 Link to this post


    Thank you for writing.

    To format the Header cells you should use the ViewCellFormatting event:
    private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
        if (e.CellElement is GridHeaderCellElement)
            e.CellElement.NumberOfColors = 1;
            e.CellElement.DrawFill = true;
            if (e.Column.ReadOnly)
                e.CellElement.BackColor = Color.Green;
                e.CellElement.BackColor = Color.Red;
            e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);

    More information about GridView cells formatting can be found here: Formatting Cells

    I hope this helps.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top