Grid Cell Colors
The cCJGrid class supports many color and style options that provide a great deal of control over a grid's appearance. A number of the color and style options control the appearance of the cells in the grid's report area (i.e., where the data are displayed). The following paragraphs describe these grid cell color settings and the order of precedence that each color setting has over the others.
Text and Background Colors
The grid object's TextColor and Color properties control the text and background color of the grid's entire report area.
If horizontal and vertical grid lines are specified to separate the grid rows and columns, then these are drawn on top of the grid's background color. The grid's peHorizontalGridStyle and peVerticalGridStyle properties control whether and how the grid lines are drawn. The piGridLineColor property controls the color of the grid lines.
None of the other color settings affect the grid area occupied by the grid lines.
Alternate Row Colors
The grid's pbUseAlternateRowBackgroundColor property controls whether the grid will paint the background of every even-numbered row using the piAlternateRowBackgroundColor.
Column Colors
Each column object can specify a different text and background color. The column object's TextColor and Color properties control the text and background color of the column's report area. These colors override the grid object's text, background, and alternate row background colors.
When a column's pbFocusable property is set to False, special colors can be applied to indicate that the column is disabled from a data entry point of view. The column's piDisabledTextColor and piDisabledColor properties control the column's text and background colors, respectively, when the column is disabled. These colors override the column's Text and TextColor properties while pbFocusable is False. When piDisabledTextColor and/or piDisabledColor are set to clNone, the disabled colors are not applied, and the column is painted as if pbFocusable were set to True.
To indicate which column has been used to sort the grid rows, after performing such a sort, a sorted column background color can be applied. The grid object's pbShadeSortColumn property controls whether the sorted column's background will be shaded. The piShadeSortColor controls which color is used to shade the sorted column. This shade sort color overrides the column's background and disabled background colors.
Custom Cell Colors
Each column's OnSetDisplayMetrics event can be used to color the text and background of each individual data cell in that column. Color settings in the display metrics event override any of the column color property settings. See Customizing the Display for Each Cell for more information.
Selected Row Colors
When the grid object's pbSelectionEnable property is set to True, the currently selected row's text and background are painted using the grid's piHighlightForeColor and piHighlightBackColor properties. These colors override all of the grid and column color settings discussed so far for the selected row.
When the application does not have the focus, a different color can be applied to the text and background of the grid's selected row. These are specified by the grid's piSelectedRowForeColor and piSelectedRowBackColor properties. By default, these properties are set to clNone, which means that special colors are not applied when the application does not have the focus.
Focused Cell Colors
When the grid object's pbFocusSubItems property is set to True, the grid is able to indicate the currently focused cell. The following properties describe how the color and appearance of the focused cell can be controlled:
-
The focused cell's text and background are painted using the grid's
piFocusCellForeColorandpiFocusCellBackColorproperties. For the focused cell, these properties override the selected row colors and all other grid and column properties discussed so far. Set these properties toclNoneto disable changing the focused cell colors. -
When the grid's
pbUseFocusCellRectangleproperty is set toTrue, a rectangular border is drawn around the perimeter of the focused cell. The grid'spiFocusCellRectangleColorcontrols the color of the focused cell rectangle. This rectangle is drawn on top of the focused cell.