ComponentOne List for WinForms
In This Topic
    Applying a Style to Specific Cell Values
    In This Topic

    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:

    Using the Designer

    1. Click the ellipsis button next to the Splits property in the Properties window to open the Split Collection Editor.
    2. In the Split Collection Editor, click the ellipsis button next to DisplayColumns property to open the C1DisplayColumn Collection Editor.
    3. In the C1DisplayColumn Collection Editor, select a column from the Members list and set the FetchStyle property to True.
    4. When finished click OK to close the C1DisplayColumn Collection Editor and the Splits Collection Editor.

    Using 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);
        }
    }
    

    This topic illustrates the following:

    When the Cell Style button is clicked, values in the CustType column greater than 3 are bold and blue.

    See Also