ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

Split.AddRegexCellStyle Method

Controls the Style used to change the appearance of cells according to their contents.

[Visual Basic]

Public Sub AddRegexCellStyle( _

ByVal condition As CellStyleFlag, _

ByVal style As C1.Win.C1TrueDBGrid.Style, _

ByVal regex As String _

)

[C#]

public void AddRegexCellStyle(

CellStyleFlag condition,

C1.Win.C1TrueDBGrid.Style style,

string regex

);

[Delphi]

public procedure AddRegexCellStyle(

condition: CellStyleFlag;

style: C1.Win.C1TrueDBGrid.Style;

regex: String

);

Parameters

condition

Combination of one or more CellStyleFlag enumerations.

style

Style object that specifies appearance attributes.

regex

A regular expression string.

Remarks

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.

The regular expressions supported by True DBGrid are a subset of standard Unix regular expression syntax:

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.

Example

The following code uses the AddRegexCellStyle method to display cells containing "SQL" with a bolded font:

·      Visual Basic

       Dim S As New C1.Win.C1TrueDBGrid.Style()

       Dim fntFont As New Font(S.Font.Name, S.Font.Size, FontStyle.Bold)

       S.Font = fntFont

       Me.C1TrueDBGrid1.AddRegexCellStyle(CellStyleFlag.NormalCell, S, "SQL")

·      C#

       C1.Win.C1TrueDBGrid.Style  S = new C1.Win.C1TrueDBGrid.Style();

       Font  fntFont = new Font(S.Font.Name, S.Font.Size, FontStyle.Bold);

       S.Font = fntFont;

       this.c1TrueDBGrid1.AddRegexCellStyle(CellStyleFlag.NormalCell, S, "SQL");

·      Delphi

       var S: C1.Win.C1TrueDBGrid.Style;

             fntFont: Font;

       S := C1.Win.C1TrueDBGrid.Style.Create;

       fntFont := Font.Create(S.Font.Name, S.Font.Size, FontStyle.Bold);

       S.Font := fntFont;

       Self.C1TrueDBGrid1.AddRegexCellStyle(CellStyleFlag.NormalCell, S,'SQL');

See Also

Split Class | Split Members | C1.Win.C1TrueDBGrid Namespace


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.