Reports for WinForms | ComponentOne
In This Topic
    Changing the Font
    In This Topic

    This topic shows how to change the Font in a single table cell, of a table column or of a table row.

    Changing the Font in a Single Table Cell

    To change the font in a single table cell, set the Font property for the cell. Add the following code to the Form_Load event before the Add and Generate methods:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    table.Cells(1, 1).Style.Font = New Font("Tahoma", 12, FontStyle.Bold)    
    table.Cells(1, 1).Style.TextColor = Color.DarkGreen
    

    To write code in C#

    C#
    Copy Code
    table.Cells[1, 1].Style.Font = new Font("Tahoma", 12, FontStyle.Bold);     
    table.Cells[1, 1].Style.TextColor = Color.DarkGreen;
    

    Changing the Font of a Table Column

    To change the font of a table column, set the Font property for the column. Add the following code to the Form_Load event before the Add and Generate methods:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    table.Cols(0).Style.Font = New Font("Arial", 12, FontStyle.Bold)
    

    To write code in C#

    C#
    Copy Code
    table.Cols[0].Style.Font = new Font("Arial", 12, FontStyle.Bold);
    

    Changing the Font of a Table Row

    To change the font of a table row, set the Font property for the row. Add the following code to the Form_Load event before the Add and Generate methods:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    table.Rows(0).Style.Font = New Font("Arial", 12, FontStyle.Bold)
    
    

    To write code in C#

    C#
    Copy Code
    table.Rows[0].Style.Font = new Font("Arial", 12, FontStyle.Bold);
    
    

    What You've Accomplished

    The following image shows how the table will appear, when you change the font in a single table cell, using the code given above. The text in cell (1,1) appears in 12 point, Dark Green, Bold Tahoma font:

    The following image shows how the table will appear, when you change the font of a table column, using the code given above. The text in the first column appears in 12 point, Bold Arial font:

    The following image shows how the table will appear, when you change the font of a table row. The text in the first row appears in 12 point, Bold Arial font: