BCGSoft.Controls.Grid Namespace : GridControl Class |
Implements a grid control class.
'Declaration Public Class GridControl Inherits System.Windows.Forms.Control Implements BCGSoft.Controls.Shared.IToolTipInfoProvider
'Usage Dim instance As GridControl
public class GridControl : System.Windows.Forms.Control, BCGSoft.Controls.Shared.IToolTipInfoProvider
public __gc class GridControl : public System.Windows.Forms.Control, BCGSoft.Controls.Shared.IToolTipInfoProvider
public ref class GridControl : public System.Windows.Forms.Control, BCGSoft.Controls.Shared.IToolTipInfoProvider
Unlike some other grids, the data displayed in the Grid control separated from the view. In this way you can create several grid controls manipulating the same data.
Use GridControlData property to assign an external GridData object to the GridControl. This object can be shared between one or more grid controls.
If you wish to create the data quickly (for unbound Grid control), just set the InitialNumberOfColumns and InitialNumberOfRows properties at design time or runtime and the data will be created internally during EndInit. You can always call CreateData to reinitialize the Grid data. These properties and methods are usable for creation of Microsoft Excel-style editable grids. CreateData creates a "flat" table with text cells. In this mode we would recommend to set OperationMode property to ContentOperationMode::RepositionData value, which means that during sort operations the Grid moves data between rows instead of changing row order.
If you have a specific data (with predefined schema) to be displayed in the Grid, then you should add GridColumn objects to the ColumnCollection and build GridDataRow objects connecting their data with columns by setting the GridColumn.DataIndex property. For example, if you have the following data structure:
{String Name , int Age, bool HasChildren}
you would create the Grid as following:
// create new data for Grid
GridData gridData = new GridData ();
// define columns
GridColumn column = new GridColumn ();
column.DataIndex = 0;
column.ColumnName = "Name";
gridControl.ColumnCollection.Add (column);
column = new GridColumn ();
column.DataIndex = 1;
column.ColumnName = "Age"
gridControl.ColumnCollection.Add (column);
column = new GridColumn ();
column.DataIndex = 2;
column.ColumnName = "HasChildren";
column.DataType = GridDataType.CheckBox; // the column displays items of type check box
gridControl.ColumnCollection.Add (column);
GridDataRow row = new GridDataRow ();
gridData.RowCollection.Add (row);
GridDataItem item = new GridDataItem ();
item.ItemData = "Tom Smith";
row.ItemCollection.Add (item); //item will be placed at position 0, which is wired to Name
item = new GridDataItem ();
item.ItemData = 45;
row.ItemCollection.Add (item); //item will be placed at position 1, which is wired to Age
item = new GridDataItem ();
item.ItemData = true;
row.ItemCollection.Add (item); //item will be placed at position 2, which is wired to HasChildren
gridControl.GridControlData = gridData;
It's possible to define cell types per column and per individual item. For the second, you have to set GridDataItem.DataType property to the desired type.
The library provides several predefined cell types and in addition you can create any custom cell types. Please see "Getting Started" and "How To" articles for more information about Grid control concepts.
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
BCGSoft.Controls.Grid.GridControl
BCGSoft.Controls.Grid.DBGrid
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2