Visual Basic: DataGrid Control

Visual Studio 6.0

Column Object

See Also   Example   Properties   Methods   Events

A Column object represents a column within a DataGrid control.


You manipulate a column in a DataGrid control by using a Column object's methods and properties. With a Column object, you can modify attributes of the column header as well as the column itself.

Note   A DataGrid object can contain only 32767 columns, as column indices are stored in integers.

To use a Column object, you can either use the Columns property of the DataGrid control directly or assign each column to a separate variable dimensioned as a Column object. The following demonstrates the latter:

Dim Col1, Col2 as Column
Set Col1 = DataGrid1.Columns(0)
Set Col2 = DataGrid1.Columns(1)
Col1.Caption = "Column 1"
Col2.Caption = "Column 2"

If often referring to the columns in a DataGrid control, you will increase performance by using the above method to assign values to columns rather than using the Columns property as in:

DataGrid1.Columns(0).Caption = "Column 1"