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

How do I make a GridDataBoundGrid and a GridControl look exactly like a GridListControl using a DataTable datasource?

 

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

Article ID: Published Date: Last Revised Date: Platform: Control:
492 04/30/2011 07/10/2014 Windows Forms GridDataBoundGrid(Classic)
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.