Using a String Grid
Student coursework applications usually require the presentation of the contents of several records at once. You can achieve this conveniently using a string grid. A string grid is essentially a rectangular grid made up of rows and columns of edit boxes. We tabulate some commonly used properties below.
|Key property||Description of property|
|Cells||A two-dimensional zero-based array giving the column number and row number of the edit box in the grid.|
|ColCount||The total number of columns including the fixed columns.|
|FixedCols||The number of columns preceding the data. Usually one fixed column is used to number the records.|
|FixedRows||The number of rows above the data. Usually one fixed row gives the field names.|
|RowCount||The number of rows displayed. Increment RowCount to create a new row.|
|Options||Set of true Boolean values with identifiers prefixed by 'go' e.g. goEditing, goRowMoving, goColSizing.|
Double click on the string grid in the form to obtain the StringGrid Editor. You can use this to put values into cells and to adjust individual column widths.
The following sections describe two versions of a demonstration program. The first example has no validation so that you can follow the code more easily. We then demonstrate the use of ComboBox cell editors and drawing in cells.