RulesManager for WinForms
実行時操作

In addition to creating and managing conditional formatting rules through code, RulesManager allows you to perform all these actions at runtime using the control's UI. It lets you use the built-in conditions or create your own custom expressions using the expression parser and formula editor, at runtime.

Conditional Formatting using Built-in Condition

Formatting can be applied to the entire grid or to a range of cells. When using a grid control, say C1FlexGrid or DataGridView, the range selection can be performed using the mouse selection. You may also specify the range explicitly in the rule editor pane wherein you can select one or more data ranges for which a rule should work. For example, the following image shows the conditional formatting applied to the complete grid wherein the cells that contains the word "Queso" are formatted.

Showing conditional formatting applied to the cells using built-in condition in the Rules Manager control

Custom Formatting by Expression

The RulesManager supports many common conditions, such as "greater than" and "starts with", but you can also create your own formatting expressions. The RulesManager has an expression parser and formula editor that can evaluate any formula that returns true or false. If the conditions are true, the cell range is formatted; if the conditions are false, the cell range is not formatted. For example, the following image shows the conditional formatting applied to a cell range wherein the cells in "UnitsInStock" column with value less than 20 are formatted.

Showing conditional formatting applied to the cells using custom expressions in the Rules Manager control

Runtime Rule Management Features

At runtime the end-user can perform many actions to manage the rules. These actions include creating, adding, editing, deleting, and applying rules, which are discussed below.

Add Rule

To add a conditional formatting rule to the Rules Manager control, you can simply click the Add rule button as shown in the image below.

Showing Add rule button in the Rules Manager control

Create Rule

You can easily create a rule in the RulesManager at runtime. The following image shows a custom conditional formatting rule created in the RulesManager control. Here, the rule applies to the cells in "UnitsOnOrder" column where the fore color and border color of the cells with value greater than 0 will be set to DarkBlue and Font style will be set to Bold.

Adding a rule at runtime

Edit Rule

There can be a scenario where you might want to modify an existing rule. This can be done by changing the range, style or condition. The following GIF shows how you can modify a rule by changing the style of an existing rule at runtime.

Editing a rule at runtime

Delete Rule

RulesManager also allows you to delete rules at runtime. To delete a rule at runtime, you can click the Remove button represented by the "bin" icon appearing next to the added rule as shown in the image below.

Deleting a rule at runtime