Articles in this section
Category / Section

How to highlight current row cell in WinForms GridControl?

5 mins read

Highlights the selected row


This can be done by handling the PrepareViewStyleInfo event and by changing the text color and the back color of the selected ranges of cells in the WinForms GridControl.

void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
   GridControlBase grid = gridControl1;
   GridCurrentCell cc = gridControl1.CurrentCell;

   // Highlight the current row with SystemColors.Highlight and bold font
   if(e.RowIndex > grid.Model.Rows.HeaderCount && e.ColIndex >    grid.Model.Cols.HeaderCount && cc.HasCurrentCellAt(e.RowIndex))
   {
      e.Style.Interior = new BrushInfo(SystemColors.Highlight);
      e.Style.TextColor = SystemColors.HighlightText;
      e.Style.Font.Bold = true;
   }
}
Private Sub gridControl1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs)
   Dim grid As GridControlBase = gridControl1
   Dim cc As GridCurrentCell = gridControl1.CurrentCell

   ' Highlight the current row with SystemColors.Highlight and bold font
   If e.RowIndex > grid.Model.Rows.HeaderCount AndAlso e.ColIndex > grid.Model.Cols.HeaderCount AndAlso cc.HasCurrentCellAt(e.RowIndex) Then
      e.Style.Interior = New BrushInfo(SystemColors.Highlight)
      e.Style.TextColor = SystemColors.HighlightText
      e.Style.Font.Bold = True
   End If
End Sub

After applying the properties, the grid is shown as follows.

Highlight the current row with current cell


   Figure
1: Highlighted the current row including current cell


Samples:

C#:  HighLightRow

VBHighLightRow

 

Conclusion

I hope you enjoyed learning about how to highlight current row cell in WinForms GridControl.

You can refer to the WinForms GridControl feature tour page to know about its other groundbreaking feature representations, WinForms GridControl documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms GridControl example to understand how to create and manipulate data.

 

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.


If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied