BCGControlBar Library for .NET
GridControl Class
Members 




Implements a grid control class.

Object Model
GridControl ClassGridDataItem ClassGridCellVisualStyle ClassCollectionWithEvents ClassObject ClassGridSelectionRange ClassExpandBoxVisualStyle ClassFieldChooser ClassFilterButtonVisualStyle ClassGridData ClassGridVisualStyleDef ClassGridCellVisualStyle ClassGridCellVisualStyle ClassGridCellVisualStyle ClassGridCellVisualStyle ClassCell ClassGridCellVisualStyle ClassGridSelectionRange ClassGridCellVisualStyle ClassSelectAllCellVisualStyle ClassGridColumn ClassToolTipEx Class
Syntax
Remarks
You can set various properties of this class to configure the Grid for particular application needs.

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.

Example

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.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            BCGSoft.Controls.Grid.GridControl
               BCGSoft.Controls.Grid.DBGrid

Requirements

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

See Also

Reference

GridControl Members
BCGSoft.Controls.Grid Namespace

Send Feedback