ComponentOne True DBGrid Pro 8
AddRegexCellStyle Method

 

Object Reference> True DBGrid Methods> AddRegexCellStyle Method

AddRegexCellStyle Method

Adds a regular expression cell condition to an object.

Syntax

object.AddRegexCellStyle condition, style, regex

Arguments

condition is a combination of one or more CellStyleConstants.

style is a Style object that specifies font and color attributes.

regex is a regular expression string.

Return Value

None

Remarks

This method allows you to control the font and color of cells within a grid, column, or split according to their contents. The status values (CellStyleConstants) specified by the condition argument determine which cells are affected:

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 floating editor MarqueeStyle property setting is in effect, 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.

-1 - dbgAllCells

All cells satisfy this condition.

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. To designate that a cell condition should apply to all cells regardless of status, use a cell status value of -1 (dbgAllCells).

The regex argument is a regular expression string that describes the pattern matching to be performed on cell contents. The regular expressions supported by True DBGrid are a subset of standard Unix regular expression syntax and are not compatible with the Visual Basic Like operator. The following special characters are supported:

p*

Any pattern followed by an asterisk matches zero or more occurrences of that pattern. For example, ab*c matches ac, abc, and abbcy (partial match).

p+

Any pattern followed by a plus sign matches one or more occurrences of that pattern. For example, ab+c matches abc and abbcy, but not ac.

[list]

A list of case-sensitive characters enclosed in brackets matches any one of those characters in the given position in the string. Character ranges can be used, as in [abcd], which is equivalent to [a-d]. Multiple ranges can also be used. For example, [A-Za-z0-9] matches any letter or digit. Bracketed patterns can also be combined with either the * or + operators. The pattern [A-Z]+ matches a sequence of one or more uppercase letters.

[^list]

If a list starts with a caret, it matches any character except those specified in the list.

. (period)

A period represents any single character.

^p

A caret at the beginning of a pattern forces a match to occur at the start of a cell. Otherwise, the pattern can match anywhere within a cell.

p$

A dollar sign at the end of a pattern forces a match to occur at the end of a cell. Otherwise, the pattern can match anywhere within a cell.

\c

Any character preceded by a backslash represents itself, unless enclosed in brackets, in which case the backslash is interpreted literally.

Any other character represents itself and will be compared with respect to case.

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 normal cells containing the letters "SQL" to be displayed in bold:

Dim S As New TrueDBGrid60.Style

S.Font.Bold = True
TDBGrid1.AddRegexCellStyle dbgNormalCell, S, "SQL"

Each time the AddRegexCellStyle 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 pair of condition and regex values, the new style setting replaces the existing one.

See Also

TDBGrid Control

TDBDropDown Control

Column Object

Split Object

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback