How to change the GridLineColor dynamically in WinForms GridControl?
Change the border style
By default, the border style is dotted lines and the border color is gray. The border color and style is applied based on the GridVisualStyles.
Solution
To change the border line color of the Grid dynamically in WinForms GridControl, use the GridLineColor property. By using this property, you can set all sides (Left, Right, Bottom, and Top) border styles of Grid. This is applied only when you set the border style using DefaultGridBorderStyle to ‘Solid’. Refer to the following code example.
C#
//Setting border line color this.grid.GridLineColor = Color.Red; //Setting border style to solid this.grid.DefaultGridBorderStyle = GridBorderStyle.Solid;
VB
'Setting border line color Me.grid.GridLineColor = Color.Red 'Setting border style to solid Me.grid.DefaultGridBorderStyle = GridBorderStyle.Solid
The following screenshot illustrates the output.
Figure 1: Grid with changed GridLineColor
Samples:
Conclusion
I hope you enjoyed learning about how to change the GridLineColor dynamically in WinForms GridControl.
You can refer to our WinForms GridControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms 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 WinForms GridControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!