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. Image for the cookie policy date

On Row Hover Highlight

Hello,

I have a GridGroupingControl object that has a few GridRelationDescriptors in its Source List Set. Essentially, I need the row to highlight to a different color when the mouse is hovered over it and also when a user clicks on a row(This should hold for the parent table and all tables underneath it). In further detail, I need to obtain the data from this row when a user clicks on it as well. Can you guys please show me a code snippet on how to do this?

Thanks!

Mike

1 Reply

AK Arun Kumar V Syncfusion Team February 19, 2013 06:26 AM UTC

Hi Mike,

Thanks for your interest in Syncfusion products.

Query:

Row to highlight to a different color.

The row can be highlighted to different color by using the following mouse hover event under the GridGrouping control Tablecontrol property and the Prepareviewstyleinfo event.

Please make use of the below code snippet and let me know if you have any other concerns.

Code:

<code>

private void GridPrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)

{

int row = -2, col =-2;

this.gridDataBoundGrid1.ViewLayout.PointToClientRowCol(this.gridDataBoundGrid1.PointToClient(Control.MousePosition), out row, out col, true, GridCellSizeKind.ActualSize);

 

if(e.RowIndex > 0 && e.ColIndex > 0)

{

if(e.RowIndex == row)

{

e.Style.TextColor = Color.Orange;

}

else

{

e.Style.TextColor = Color.Black;

}

}

}

 

private void GridCellMouseHoverLeave(object sender, Syncfusion.Windows.Forms.Grid.GridCellMouseEventArgs e)

{

this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.None);

}

 

private void GridCellMouseHoverEnter(object sender, Syncfusion.Windows.Forms.Grid.GridCellMouseEventArgs e)

{

this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.None);

}

</code>

 

Regards,

Arun.


Loader.
Live Chat Icon For mobile
Up arrow icon