)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change the row color on mouse hover in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: January 3, 2016 |
Last Revised Date: December 31, 2019
Tags: row, color, mousehover

Change the row color

By default, the current record will be highlighted if record is selected. If you want to change the row color while hovering the mouse, it can be achieved by handling the TableControlCellMouseHoverEnter, TableControlCellMouseHoverLeave and QueryCellStyleInfo events. Refer the below code snippet,

C#

//Invoke the events to change the color of row during the mouse hover.
this.gridGroupingControl1.TableControlCellMouseHoverEnter += gridGroupingControl1_TableControlCellMouseHoverEnter;
this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo;
 
void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
    if (hoveredIndex == e.TableCellIdentity.RowIndex)
    {
        //Set the back color for the mouse hovered row.
        e.Style.BackColor = Color.LightBlue;
    }
}
 
void gridGroupingControl1_TableControlCellMouseHoverEnter(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellMouseEventArgs e)
{
    //Set the hovered row index to change the backcolor.
    hoveredIndex = e.Inner.RowIndex;
    this.gridGroupingControl1.TableControl.Refresh();
}            

 

VB

'Invoke the events to change the color of row during the mouse hover.
Me.gridGroupingControl1.TableControlCellMouseHoverEnter += gridGroupingControl1_TableControlCellMouseHoverEnter
Me.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo
 
Dim hoveredIndex As Integer =-1
 
Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs)
   If hoveredIndex = e.TableCellIdentity.RowIndex Then
      'Set the back color for the mouse hoverd row.
      e.Style.BackColor = Color.LightBlue
   End If
End Sub
 
Private Sub gridGroupingControl1_TableControlCellMouseHoverEnter(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellMouseEventArgs)
   'Set the hovered row index to change the backcolor.
   hoveredIndex = e.Inner.RowIndex
   Me.gridGroupingControl1.TableControl.Refresh()
End Sub

 

Screenshot

Change the row color while hovering the mouse on the row

Samples:

C#: MouseHover_CS

VB: MouseHover_VB

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon