You can tell List for WinForms to automatically apply colors and fonts to particular cells, based upon their displayed contents. To do so, you provide a pattern, called a regular expression, which the list tests against the displayed value of each cell. Using the AddRegexCellStyle method, you can associate a regular expression with a set of style attributes, and then apply them to any possible combination of cell status values. The AddRegexCellStyle method is supported by the C1List, C1Combo, Split, and C1DisplayColumn objects, allowing you to control the range of cells for which certain conditions apply.
The AddRegexCellStyle method is similar to the AddCellStyle method, but it requires an additional argument for the regular expression string. As with AddCellStyle, you can use either temporary or named styles. The following example uses a temporary style to display all cells in the first column that contain the string "Computer" in bold:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Dim S As New C1.Win.C1List.Style() Dim myfont As Font myfont = New Font(S.Font, FontStyle.Bold) S.Font = myfont Me.C1List1.Splits(0).DisplayColumns(0).AddRegexCellStyle(C1.Win.C1List.CellStyleFlag.AllCells, S, "Computer") |
To write code in C#
C# |
Copy Code
|
---|---|
C1.Win.C1List.Style S = new C1.Win.C1List.Style(); Font myfont; myfont = new Font(S.Font, FontStyle.Bold); S.Font = myfont; this.c1List1.Splits[0].DisplayColumns[0].AddRegexCellStyle(C1.Win.C1List.CellStyleFlag.AllCells, S, "Computer"); |
This feature allows you to implement "visual queries" that attach distinctive font or color attributes to cells that match a certain pattern.