True DBGrid for WinForms | ComponentOne
Working with Objects and Collection / Collections
In This Topic
    Collections
    In This Topic

    A collection is an object used to group similar data items, such as grid columns or styles. In general, a group of similar items in True DBGrid is implemented as a collection. Since a collection is an object, it can be manipulated in code just like any other object. True DBGrid in WinForms exposes the following collections:

    Collection Description
    C1DataColumnCollection

    Contains zero or more C1DataColumn objects in a grid.

    The C1TrueDBGrid control and the C1TrueDBDropDown control both maintain a C1DataColumnCollection object to hold and manipulate C1DataColumn objects. This collection is contained under the C1TrueDBGrid object, and can be modified through the C1TrueDBGrid Designer. It can be accessed through the Columns property of the True DBGrid for WinForms controls.

    C1DisplayColumnCollection

    Contains zero or more C1DisplayColumn objects in a grid.

    The C1TrueDBGrid control and the C1TrueDBDropDown control both maintain a C1DisplayColumnCollection object to hold and manipulate C1DisplayColumn objects. This collection is contained under the Split object, and is available through the Split's DisplayColumns property. In addition, this collection can be modified in .NET through the C1DisplayColumnCollection Editor.

    GroupedColumnCollection

    Contains zero or more C1DataColumn objects in the grouping area.

    When the DataView property is set to DataViewEnum.GroupBy, a grouping area is created above the grid. This collection object represents the columns (C1DataColumn object) in the grouping area. As columns are dragged into or dragged out of the grouping area, the corresponding column in the collection will be added or deleted.

    SelectedRowCollection

    Contains zero or more selected row indexes.

    When the user selects and highlights one or more rows of a C1TrueDBGrid control at run time, the row index of the selected rows are stored in the SelectedRowCollection object. In code, the Item property and IndexOf method of the collection can be used to determine which rows are selected. Also select and deselect records programmatically using its Add and RemoveAt methods.

    SelectedColumnCollection

    Contains zero or more C1DataColumn objects that represent selected columns.

    When the user selects and highlights one or more columns of a C1TrueDBGrid control at run time, the C1DataColumn objects for those rows are stored in the SelectedColumnCollection object. In code, use the Item property and IndexOf method of the collection to determine which rows are selected. Also select and deselect records programmatically using its Add and RemoveAt methods.

    SplitCollection

    Contains one or more Split objects in a grid.

    The C1TrueDBGrid control maintains a SplitCollection collection to hold and manipulate Split objects. A grid has one split by default, but may contain multiple splits. This collection is accessed using the Splits property of the C1TrueDBGrid. In addition this collection can be modified in .NET through the Split Collection Editor.

    GridStyleCollection

    Contains built-in and user-defined Style objects for a grid.

    The C1TrueDBGrid and C1TrueDBDropDown controls store all built-in and user-defined Style objects in the GridStyleCollection object. Access the members of this collection by name in code, and then apply them to a grid, column, or split in order to control the appearance of the object in question. This collection is accessed using the Styles property in the True DBGrid for WinForms controls.

    ValueItemCollection

    Contains zero or more ValueItem objects for a column.

    Each C1DataColumn object within a C1TrueDBGrid or C1TrueDBDropDown control stores its set of display value/value pairs in objects called ValueItem objects. The ValueItemCollection object is a collection of these pairs. This collection can be accessed through the Values property of the ValueItems object. For instance, in order to alter the first ValueItem in the collection, the code would look like:

    C#
    Copy Code
    this.c1TrueDBGrid.Columns[0].ValueItems.Values[0].DisplayValue = "Canada";