ComponentOne List for WinForms
In This Topic
    Modifying a Style Property Directly
    In This Topic

    You can customize the appearance of a list component by modifying one or more members of an appropriate style property. For example, to make the list's caption text bold, you can change the Font property associated with the CaptionStyle property. At design time, this is done by expanding the CaptionStyle tree node on the Properties window, expanding the Font node, and setting Bold to True. The change is committed to the list when you click out of this particular property.

    Note that if you switch to the Style Collection Editor, you will see that the built-in Caption style has not changed.

    This means that the following statements are not equivalent:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1List1.CaptionStyle.Font = New Font(Me.C1List1.CaptionStyle.Font, FontStyle.Bold)        
    Me.C1List1.Styles("Caption").Font = New Font(Me.C1List1.Styles("Caption").Font, FontStyle.Bold)
    

    To write code in C#

    C#
    Copy Code
    this.c1List1.CaptionStyle.Font = new Font(this.c1List1.CaptionStyle.Font, FontStyle.Bold);        
    this.c1List1.Styles["Caption"].Font = new Font(this.c1List1.Styles["Caption"].Font, FontStyle.Bold);
    

    The first statement specifies the font of the list's caption bar without changing the named Caption style. The second statement changes the named Caption style, which may or may not affect the display of the list's caption bar, depending on whether the Font member of the CaptionStyle property was specialized previously. For example, if you change the list's CaptionStyle font to Arial, then change the font of the built-in Caption style to Courier, the list caption will remain Arial. However, if you never change the CaptionStyle font, then any font change to the built-in Caption style will be instantly reflected in the list's caption bar.