Object Reference > True DBGrid Methods > AddCellStyle Method |
AddCellStyle Method
Adds a cell condition to an object.
object.AddCellStyle condition, style
Arguments
condition is a combination of one or more CellStyleConstants.
style is a Style object that specifies font and color attributes.
Return Value
None
This method allows you to control the font and color of cells within a grid, column, or split according to the status values (CellStyleConstants) specified by the condition argument:
1 - dbgCurrentCell |
The cell is the current cell as specified by the Bookmark, Col, and Split properties. At any given time, only one cell can have this status. When the MarqueeStyle property is set to 6 - Floating Editor, this condition is ignored. |
2 - dbgMarqueeRow |
The cell is part of a highlighted row marquee. When the MarqueeStyle property indicates that the entire current row is to be highlighted, all visible cells in the current row have this additional condition set. |
4 - dbgUpdatedCell |
The cell contents have been modified by the user but not yet written to the database. This condition is also set when cell contents have been modified in code with the Text or Value properties. |
8 - dbgSelectedRow |
The cell is part of a row selected by the user or in code. The SelBookmarks collection contains a bookmark for each selected row. |
0 - dbgNormalCell |
The cell satisfies none of these conditions. |
You can add the first four values together to specify multiple cell conditions. For example, a cell status value of 9 (dbgCurrentCell + dbgSelectedRow) denotes a current cell within a selected row. You can also use a cell status value of 0 (dbgNormalCell) to refer to only those cells without any of the four basic cell conditions.
The style argument specifies the attributes that will override the default font and color characteristics for cells within an object. For example, the following code causes updated cells to be displayed in red:
Dim S As New TrueDBGrid60.Style
S.ForeColor = vbRed
TDBGrid1.AddCellStyle dbgUpdatedCell, S
Each time the AddCellStyle method is invoked, the specified cell condition is added to the list of existing conditions. Hence, by repeated use of this method it is possible to set up multiple conditions to affect the appearance of a grid, column, or split.
Note
If a cell condition already exists for a particular condition value, the new style setting replaces the existing one.