| List for WinForms Task-Based Help > Applying a Style to Specific Cell Values |
To apply a style to specific values in a cell, use the FetchStyle property and the FetchCellStyle event. You can set the FetchStyle property to True using the designer or in code:


Alternatively, you can add code to set the FetchStyle property. In the following example the code was added to the Button1_Click event:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.C1List1.Splits(0).DisplayColumns.Item("CustType").FetchStyle = True
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.c1List1.Splits[0].DisplayColumns["CustType"].FetchStyle = true; |
|
Add the following FetchCellStyle event to set all CustType greater than 3 to bold and blue.
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub C1List1_FetchCellStyle(ByVal sender As Object, ByVal e As C1.Win.C1List.FetchCellStyleEventArgs) Handles C1List1.FetchCellStyle
Dim custtype As Long
custtype = Val(Me.C1List1.Columns(e.Col).CellText(e.Row))
If custtype > 3 Then
e.CellStyle.ForeColor = System.Drawing.Color.Blue
e.CellStyle.Font = New Font(e.CellStyle.Font, FontStyle.Bold)
End If
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void c1List1_FetchCellStyle(object sender, C1.Win.C1List.FetchCellStyleEventArgs e)
{
long custtype;
custtype = long.Parse(this.c1List1.Columns[e.Col].CellText(e.Row));
if (custtype > 3)
{
e.CellStyle.ForeColor = System.Drawing.Color.Blue;
e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold);
}
}
|
|
When the Cell Style button is clicked, values in the CustType column greater than 3 are bold and blue.
