Version

Implementing Conditional Formatting at Design Time

Conditional Formatting allows you to add rules to a WinGrid™ column that conditionally formats cells if the rule evaluates to true. You can define Conditional Formatting rules in the WinGrid during runtime using the Conditional Formatting dialog. The dialog is available via the Columns Collection Editor through the ValueBasedAppearance property.

Note
Note

Design time conditional formatting is only possible if the WinGrid’s DataSource is set at design time. The design time configuration is required so the IDE is aware of which columns are defined in the data, and therefore the ValueBasedAppearance property is available to be set.

Showing the Conditional Formatting Dialog at Design Time

To show the conditional formatting dialog, follow these steps:

  1. With WinGrid selected on the form, expand the DisplayLayout object in the Properties window.

  2. Navigate to the Bands collection and expand it.

  3. Expand the band of your choice.

  4. Find the Columns collection and click the ellipsis. The Columns Collection Editor appears.

Win Implementing Conditional Formatting at Design Time 01.png
  1. Click the ellipsis to the right of the ValueBasedAppearance property. The Conditional Formatting dialog box appears.

Win Implementing Conditional Formatting at Design Time 02.png

Creating a Condition

The steps below demonstrate the process of creating an Operator condition through the conditional formatting dialog. A column containing an integer is used in this example.

  1. Click the “Select a condition type” drop down, and select Operator.

  2. Click the comparison operator drop down and select GreaterThanOrEqualTo.

  3. In the editor, type the value 5.

  4. Using the appearance drop down, configure the cell’s appearance to your liking. Your condition should look similar to the following.

Win Implementing Conditional Formatting at Design Time 03.png
  1. Click OK to close the Conditional Formatting Dialog.

  2. Click OK to the close the Columns Collection Editor. The appearance condition is now set on the grid. Running your application will show the conditional formatting in the grid.

Win Implementing Conditional Formatting at Design Time 04.png