FlexGrid for WinForms
Setting the Background Color of Columns and Rows
Show AllShow All
Hide AllHide All

To set the background color of columns and rows, create a new style and assign it to a column and row.

Setting the Background Color of Columns

  1. Create a new style for the column.

    In the Designer

    • Open the C1FlexGrid Style Editor. For details on how to access the C1FlexGrid Style Editor, see Accessing the C1FlexGrid Style Editor.
    • Click Add to create a new style.
    • Double-click CustomStyle1, rename it ColumnColor, and press ENTER when finished.
    • Do not exit the C1FlexGrid Style Editor.

    In Code

    Add the following code to the Form_Load event:

    To write code in Visual Basic

    To write code in C#

  2. Set the BackColor color to CornSilk.

    In the Designer

    • In the C1FlexGrid Style Editor, locate the BackColor property in the right pane and set it to CornSilk.
    • Click OK to close the C1FlexGrid Style Editor.

    In Code

    Add the following code to the Form_Load event:

    To write code in Visual Basic

    To write code in C#

  3. Assign the style to a column by adding the following code to the Form_Load event:

    To write code in Visual Basic

    To write code in C#

This topic illustrates the following:

The background color of the Element column is set to CornSilk.

Setting the Background Color of Rows

  1. Create a new style for the row.

    In the Designer

    • Open the C1FlexGrid Style Editor. For details on how to access the C1FlexGrid Style Editor, see Accessing the C1FlexGrid Style Editor.
    • Click Add to create a new style.
    • Double-click CustomStyle1, rename it RowColor, and press ENTER when finished.
    • Do not exit the C1FlexGrid Style Editor.

    In Code

    Add the following code to the Form_Load event:

    To write code in Visual Basic

    To write code in C#

  2. Set the BackColor to PowderBlue.

    In the Designer

    • In the C1FlexGrid Style Editor, locate the BackColor property and set it to PowderBlue.
    • Click OK to close the C1FlexGrid Style Editor.

    In Code

    To write code in Visual Basic

    To write code in C#

  3. Assign the style to a row by adding the following code to the Form_Load event:

    To write code in Visual Basic

    To write code in C#

This topic illustrates the following:

The background color of the row is set to PowderBlue. Notice how the column color takes precedence over the row color.


 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback