ComponentOne True DBGrid for WinForms
Setting the Font Style of a Column
True DBGrid for WinForms Task-Based Help > Setting the Grid's Appearance > Setting the Font Style of a Column

The font style of a column can be set either in the designer or in code.

In the Tasks Menu

To set the font style using the C1TrueDBGrid Tasks menu, complete the following steps:

  1. Select the Country column in the grid and click it to open the C1TrueDBGrid Tasks menu.
  2. Select Column Style from the menu.
  3. Click the ellipsis button after the Font property to open the Font dialog box.
  4. Set the Font to Times New Roman, the Font style to Bold, and click OK to close the Font dialog box.
  5. Click OK to close the Column Style(Country) dialog box.

In the Designer

Alternatively, the font style can also be set through the C1TrueDBGrid Designer. To set the font style using the designer:

  1. Open the C1TrueDBGrid Designer. For information on how to access the C1TrueDBGrid Designer, see Accessing the C1TrueDBGrid Designer.
  2. Select the Country column by selecting it's column header from the right pane.
    The column can also be selected by choosing Country from the drop-down list on the toolbar.
  3. Set the font to Times New Roman and click Bold on the toolbar.
  4. Click OK to close the designer.

In Code

To set the font style using code, complete the following steps:

  1. Declare a new font variable:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim fntFont As Font
    

    To write code in C#

    C#
    Copy Code
    Font fntFont;
    
  2. Set the desired column's font to the new font variable:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    fntFont = New Font("Times New Roman", Me.C1TrueDBGrid1.Splits(0).DisplayColumns.Item("Country").Style.Font.Size, FontStyle.Bold)
    Me.C1TrueDBGrid1.Splits(0).DisplayColumns.Item("Country").Style.Font = fntFont
    

    To write code in C#

    C#
    Copy Code
    fntFont = new Font("Times New Roman", this.c1TrueDBGrid1.Splits[0].DisplayColumns["Country"].Style.Font.Size, FontStyle.Bold); 
    this.c1TrueDBGrid1.Splits[0].DisplayColumns["Country"].Style.Font = fntFont;
    

What You've Accomplished

In this example, the rows of the Country column are now Times New Roman font and bold:


For more information on specifying cell styles, see Applying Styles to Cells.