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

Change background color of row indicator cell

1 Answer 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 16 Nov 2018, 06:51 AM

Hi,

For the Row indicator column on the very left. I would like to change the background color based on an entry on one of the row values. 

I have checked out this article - https://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells

But do not know the type in order to get the row indicator cell/column

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Nov 2018, 02:26 PM
Hello, Terry, 

In order to customize the grid cells, it it suitable to use the CellFormatting/ViewCellFormatting event as you have already found out. You can find below a sample code snippet demonstrating how to color the indicator cells:

private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
    GridRowHeaderCellElement rowHeader = e.CellElement as GridRowHeaderCellElement;
    if (rowHeader != null)
    {
        e.CellElement.DrawFill = true;
        e.CellElement.BackColor = Color.Red;
        e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
    }
}

I would recommend you to use the RadControlSpyForm tool which is quite useful for inspecting the elements. Thus, you can find very easily which elements to customize.

I hope this information helps.

Regards,
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.
Tags
GridView
Asked by
Terry
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or