Working with the Grid Control

The Grid control is an ActiveX control that provides a visual interface to display data in table form. For example, you can use a Grid control to create an application interface that is similar in appearance to Microsoft® Excel.

The Grid control is divided into rows and columns. An intersection of a row and a column is called a cell. You can change the formatting of the Grid as a whole, or cell by cell. The following table shows properties and methods that determine the appearance of a Grid control.

Property
Description
Cols Number of columns in the Grid.
Rows Number of rows in the Grid.
TopRow Row number of the upper row shown.
LeftCol Column number of the leftmost column shown.
ColAlignment Alignment used by a column.
CellAlignment Alignment used by a cell. Overrides ColAlignment.
BackColor Default background color of all cells.
CellBackColor Background color of a cell. Overrides BackColor.
BackColorBkg Background color for Grid area not covered by cells.
BackColorSel Background color of selected cells.
ForeColor Default text color of all cells.
CellForeColor Text color of a cell. Overrides ForeColor.
ForeColorSel Text color of selected cells.
TextStyle Text appearance. Can be normal, raised, or inset.
GridColor Color of grid lines.
GridLines Grid line appearance. Can be raised, inset, normal, or none.
GridLineWidth Width of Grid lines.

The Grid control also supplies properties, such as CellFontBold, that determine standard text effects.

In addition to the cell properties, you can change the height of rows or the width of columns with the RowHeight and ColWidth properties. By default, rows automatically resize in proportion to the text in the row. You can set the RowHeightMin property to specify a minimum row height for cells with small fonts. Setting the WordWrap property to True can increase the default height of rows if a cell displays multiple lines of text.