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: