Formatting Grids
You can customize the format for grids in various ways.
Using Conditional Formatting in Grids
Special formatting in a grid can make it easier for a user to scan through the records in the grid and locate certain information. To provide conditional formatting, use the dynamic font and color properties of a column.
For example, you can add a grid to a form and set the ColumnCount property to 2. Set the ControlSource property of the first column to orders.to_name and the ControlSource property of the second column to orders.order_net. To display order totals less than 500.00 with a forecolor of black and order totals greater than or equal to 500.00 with a foreground color of red, include the following line in the grid's Init event code:
THIS.Column2.DynamicForeColor = ;
"IIF(orders.order_net >= 500, RGB(255,0,0), RGB(0,0,0))"
Common Grid Properties
The following grid properties are commonly set at design time.
Property |
Description |
---|---|
The foreign key of the child table that is joined with the primary key of the parent table. |
|
Number of columns. If ColumnCount is set to - 1, the grid has as many columns as there are fields in the grid's RecordSource. |
|
The parent table for child records displayed in the grid. |
|
The data to be displayed in the grid. |
|
Where the data displayed in the grid comes from: a table, an alias, a query, or a table selected by the user in response to a prompt. |
Common Column Properties
The following column properties are commonly set at design time.
Property |
Description |
---|---|
The data to be displayed in the column. This is often a field in a table. |
|
If Sparse is set to true (.T.), controls in a grid are displayed as controls only when the cell in the column is selected. Other cells in the column display the underlying data value in a text box. Setting Sparse to true (.T.) allows faster repainting if a user is scrolling through a grid with a lot of displayed rows. |
|
Which control in the grid is active. The default is Text1, but if you add a control to the column, you can specify it as the CurrentControl. |
Note
The ReadOnly property of a control inside the column is overridden by the ReadOnly property of the Column. If you set the ReadOnly property of the control in a column in the code associated with the AfterRowColChange event, the new setting will be valid while you are in that cell.
See Also
Tasks
How to: Set Up a One-to-Many Form Using the Grid Control
How to: Make Controls Easier to Use
Concepts
Controls and Objects Created in Earlier Versions
Reference
Controls for Manipulating Rows of Data