ComponentOne True DBGrid for WinForms
How to Use Styles / Working with Style Properties / Modifying a Style Property Directly
In This Topic
    Modifying a Style Property Directly
    In This Topic

    Customize the appearance of a grid component by modifying one or more members of an appropriate style property. For example, to make the grid's caption text bold, change the Font object 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 the Boldproperty to True. The change is committed to the grid when you click out of this particular property.

    Note when switching to the C1TrueDBGrid Style Editor, it will be seen 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
    Dim myfont As New Font(Me.C1TrueDBGrid1.Font, FontStyle.Bold)
    Me.C1TrueDBGrid1.CaptionStyle.Font = myfont
     
    Me.C1TrueDBGrid1.Styles("Caption").Font = myfont
    

    To write code in C#

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

    The first statement specifies the font of the grid's caption bar; because this is a root style, the named Caption style also changes.

    See Also