Articles in this section
Category / Section

How to format the entire grid to look like Microsoft's flat style in WinForms GridControl?

4 mins read

Format the entire grid

In an XP system, you can get a flat XP look by setting grid.ThemesEnabled as true. You can get Microsoft’s flat style by setting certain properties to flatten the different parts of the WinForms GridControl.

Refer to the following code examples.

C#

//set grid borderstyle
this.gridDataBoundGrid1.BorderStyle = BorderStyle.FixedSingle;
//make headers be static cells to avoid raised drawing
this.gridDataBoundGrid1.BaseStylesMap["Header"].StyleInfo.CellType = "Static";
this.gridDataBoundGrid1.BaseStylesMap["Column Header"].StyleInfo.CellType = "Static";
this.gridDataBoundGrid1.BaseStylesMap["Row Header"].StyleInfo.CellType = "Static";
//set the header borders to draw
GridStyleInfo style = new GridStyleInfo(); 
GridBorder gb = new GridBorder(GridBorderStyle.Solid, SystemColors.ControlDark);
style.Borders.Bottom = gb;
style.Borders.Right = gb;
this.gridDataBoundGrid1.BaseStylesMap["Header"].StyleInfo.ModifyStyle(style,  Syncfusion.Styles.StyleModifyType.Override);
this.gridDataBoundGrid1.BaseStylesMap["Column Header"].StyleInfo.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override);
this.gridDataBoundGrid1.BaseStylesMap["Row Header"].StyleInfo.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override);
//set the borders for all non header cells...this.gridDataBoundGrid1.Model.Options.DefaultGridBorderStyle = GridBorderStyle.Solid;

 

VB

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'set grid borderstyle
    Me.gridDataBoundGrid1.BorderStyle = BorderStyle.FixedSingle
    'make headers be static cells to avoid raised drawing
    Me.gridDataBoundGrid1.BaseStylesMap("Header").StyleInfo.CellType = "Static"
    Me.gridDataBoundGrid1.BaseStylesMap("Column Header").StyleInfo.CellType = "Static"
    Me.gridDataBoundGrid1.BaseStylesMap("Row Header").StyleInfo.CellType = "Static"
    'set the header borders to draw
    Dim style As New GridStyleInfo()
    Dim gb As New GridBorder(GridBorderStyle.Solid, SystemColors.ControlDark)
    style.Borders.Bottom = gb
    style.Borders.Right = gb
    Me.gridDataBoundGrid1.BaseStylesMap("Header").StyleInfo.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override)
    Me.gridDataBoundGrid1.BaseStylesMap("Column Header").StyleInfo.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override)
    Me.gridDataBoundGrid1.BaseStylesMap("Row Header").StyleInfo.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override)
    'set the borders for all non header cells...
    Me.gridDataBoundGrid1.Model.Options.DefaultGridBorderStyle = GridBorderStyle.Solid
End Sub

 

Samples:

C#: Microsoft Flat Style CS

VB: Microsoft Flat Style VB

Conclusion

I hope you enjoyed learning about how to format the entire grid to look like Microsoft's flat style 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 forumsDirect-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 sign in to leave a comment
Access denied
Access denied