ComponentOne List for WinForms
Styling and Appearance / Custom Styles
In This Topic
    Custom Styles
    In This Topic

    List enables you to style the control using custom styles. Let us explore how to style the list and its content using the custom styles.

    Create Custom Style

    For applying custom styles, you need to create a custom style as an object of the Style class and add it to the Styles collection using the Add method. Then, define its properties and apply it to a row, column or cell range whenever required. This approach is very useful when you need to repeatedly use a particular style.

    Use the following code to create re-usable custom styles for the List control.

    C#
    Copy Code
    //define a custom style
    Style customStyle = new Style();
    customStyle.BackColor = Color.Yellow;
    customStyle.ForeColor = Color.Blue;
    
    //Add custom style to style collection 
    c1List1.Styles.Add(customStyle);
    
    //assign custom style
    c1List1.Splits[0].DisplayColumns[2].Style = customStyle;
    c1List1.Splits[0].DisplayColumns[4].Style = customStyle;