)
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. (Last updated on: June 24, 2019).
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 |
Published Date: April 30, 2011 |
Last Revised Date: December 16, 2019
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 grid.

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

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
Live Chat Icon