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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: GridControl
Tags: formatting

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!

 

 

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