FlexGrid for WinForms
Formatting Cells Based on the Contents
Show AllShow All
Hide AllHide All

To conditionally format cells based on the contents, create a new style and use the CellChanged event.

  1. Create a new CellStyle called LargeValue and set the BackColor property to Gold.

    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 LargeValue, and press ENTER when finished.
    • Locate the BackColor property in the right pane and set it to Gold.
    • Locate the Font property and click the ellipsis button next to it to open the Font dialog box.
    • Set the Font style box to Italic.
    • Click OK to close the Font dialog box.
    • 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#

  2. Use the CellChanged event to format the cells based on the contents:

    To write code in Visual Basic

    To write code in C#

This topic illustrates the following:

In this example, cells containing values greater than or equal to 50,000 are highlighted in gold.


 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback