Radgridview current column : changing backcolor of the column's header

2 posts, 1 answers
  1. George C.
    George C. avatar
    29 posts
    Member since:
    Sep 2018

    Posted 24 Dec 2019 Link to this post



    Supposing that a Radgridview has 4 columns and the second one is the current column (our target).

    Is it possible to change backcolor of not all the rows of the current column, but only the header cell of the color  ? As if the column is highlighted or selected

    I attached a picture

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    3952 posts

    Posted 25 Dec 2019 Link to this post

    Hello, George,     

    The appropriate way to customize the header cell elements is to use the ViewCellFormatting event. Please refer to the following code snippet which demonstrates how to change the color of the header cell for a particular column. 

            private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
                if (e.CellElement is GridHeaderCellElement && e.Column.Name == "ProductName")
                    e.CellElement.DrawFill = true;
                    e.CellElement.GradientStyle = GradientStyles.Solid;
                    e.CellElement.BackColor = Color.Red;
                    e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
                    e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
                    e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Happy Holidays

    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top