RadGridView Header colors on hover

4 Answers 289 Views
GridView
Paul
Top achievements
Rank 1
Iron
Paul asked on 16 Aug 2021, 03:19 PM
Is it possbile to set the colours when the mouse hovers over the column headers. I expected a SetThemeValueOverride but couldn't find aything. They currently default to light yellow.

4 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 17 Aug 2021, 11:44 AM

Hello, Paul,

You can use the following code snippet to change the hover color of the column headers in the grid using the SetThemeValueOverride method:

private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridHeaderCellElement)
    {
        e.CellElement.SetThemeValueOverride(LightVisualElement.BackColorProperty, Color.LightGreen, "MouseOver");
        e.CellElement.SetThemeValueOverride(LightVisualElement.GradientStyleProperty, GradientStyles.Solid, "MouseOver");

    }
    else
    {
        e.CellElement.ResetThemeValueOverride(LightVisualElement.BackColorProperty, "MouseOver");
        e.CellElement.ResetThemeValueOverride(LightVisualElement.GradientStyleProperty, "MouseOver");
    }
}

I hope this helps. If you have other questions do not hesitate to contact me.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Paul
Top achievements
Rank 1
Iron
answered on 17 Aug 2021, 01:16 PM
Perfect - your response has solved my problem perfectly
Paul
Top achievements
Rank 1
Iron
commented on 17 Aug 2021, 01:17 PM | edited

Is it possible to move the "down" and "up" arrows to perhaps the right hand side of the header column?

 

Also - The colors do not return to the state when not hovered as I cannot reset the styles as you suggest as the other rows have styling applied too

0
Nadya | Tech Support Engineer
Telerik team
answered on 18 Aug 2021, 09:25 AM

Hello, Paul,

I suppose that you have enabled sorting in RadGridView and you would like to manage the position of the up/down arrow. Please refer to the following forum thread that demonstrates how you can achieve this: https://www.telerik.com/forums/change-the-position-of-the-arrow-(sort)-in-the-header-of-the-grid#5174997 

According to your second question, note that RadGridView uses UI virtualization for its cells and rows. This means that the visible cells/rows are reused during scrolling, filtering, and other operations with the grid. This is why it is important to reset all of the applied customizations that you have made in the formatting events. More information is available here: 
https://docs.telerik.com/devtools/winforms/controls/gridview/fundamentals/ui-virtualization 
https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells 

I hope this helps. If you have other questions please let me know.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Paul
Top achievements
Rank 1
Iron
answered on 18 Aug 2021, 09:57 AM
Perfect :)
Tags
GridView
Asked by
Paul
Top achievements
Rank 1
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Paul
Top achievements
Rank 1
Iron
Share this question
or