)
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 do I make a GridDataBoundGrid and a GridControl look exactly like a GridListControl using a DataTable datasource?

Platform: WinForms |
Control: GridDataBoundGrid(Classic) |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

This can be done by hiding the row headers and setting the ListBoxSelectionMode to one and by adjusting some color properties.

C#

//in Form constructor

this.gridDataBoundGrid1.BaseStylesMap["Header"].StyleInfo.Themed = false;

this.gridDataBoundGrid1.BaseStylesMap["row Header"].StyleInfo.Interior = new BrushInfo(GradientStyle.Horizontal, Color.FromArgb(203, 199, 184), Color.FromArgb(238, 234, 216));

this.gridDataBoundGrid1.BaseStylesMap["Header"].StyleInfo.Interior = new BrushInfo(GradientStyle.Horizontal, Color.FromArgb(203, 199, 184), Color.FromArgb(238, 234, 216));

in the Form Load event

//GridControl

this.gridControl1.RowCount = 10;

this.gridControl1.ColCount = 4;

this.gridControl1.Cols.Hidden[0] = true;

this.gridControl1.ReadOnly = true;

this.gridControl1.ListBoxSelectionMode = SelectionMode.One;

//DataBoundGrid

this.gridDataBoundGrid1.Model.Cols.Hidden[0] = true;

this.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.One;

this.gridDataBoundGrid1.BorderStyle = BorderStyle.FixedSingle;

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)

{

if (e.RowIndex == 0)

{

e.Style.Font.Bold = true;

e.Style.BackColor = Color.FromKnownColor(KnownColor.Control);

}

}

VB

'in Form constructor

Private Me.gridDataBoundGrid1.BaseStylesMap("Header").StyleInfo.Themed = False

Private Me.gridDataBoundGrid1.BaseStylesMap("row Header").StyleInfo.Interior = New BrushInfo(GradientStyle.Horizontal, Color.FromArgb(203, 199, 184), Color.FromArgb(238, 234, 216))

Private Me.gridDataBoundGrid1.BaseStylesMap("Header").StyleInfo.Interior = New BrushInfo(GradientStyle.Horizontal, Color.FromArgb(203, 199, 184), Color.FromArgb(238, 234, 216))

'GridControl

in the Form Load RowCount As [event] = 10

Me.gridControl1.ColCount = 4

Me.gridControl1.Cols.Hidden(0) = True

Me.gridControl1.ReadOnly = True

Me.gridControl1.ListBoxSelectionMode = SelectionMode.One

'DataBoundGrid

Me.gridDataBoundGrid1.Model.Cols.Hidden(0) = True

Me.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.One

Me.gridDataBoundGrid1.BorderStyle = BorderStyle.FixedSingle

private void gridDataBoundGrid1_PrepareViewStyleInfo(Object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)

If e.RowIndex = 0 Then

e.Style.Font.Bold = True

e.Style.BackColor = Color.FromKnownColor(KnownColor.Control)

End If

Here is a sample that illustrates this:

http://help.syncfusion.com/support/samples/kb/Grid.Windows/GridListControlLook/Grids_GridListControlLook.zip

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