Skip to main content
A newer version of this page is available. .

Formatting Values Using Icon Sets

  • 3 minutes to read

The Icon Sets conditional format allows you to use predefined or custom icon sets to format different value ranges.

The image below shows a grid column whose Profit cells contain icons corresponding to numeric values.

CFIconSetsExample

This topic consists of the following sections:

Adding Rules in Code

Create the IconSetFormatCondition class instance and specify the following settings to create a conditional format in code:

The following code sample illustrates how to define a conditional format in markup:

<dxg:TableView.FormatConditions>
   <dxg:IconSetFormatCondition FieldName="Profit" PredefinedFormatName="Stars3IconSet"/>
</dxg:TableView.FormatConditions>

The code sample below illustrates how to define the same conditional format in code-behind:

var profitFormatCondition = new IconSetFormatCondition() {
   FieldName = "Profit",
   PredefinedFormatName = "Stars3IconSet"
};
view.FormatConditions.Add(profitFormatCondition);

Adding Rules Using Conditional Formatting Menu

  1. Select the Icon Sets item in the Conditional Formatting Menu.
  2. Choose the required icon set in the invoked sub menu. The conditional formatting menu allows you to use only predefined Icon Sets formats stored within the TableView.PredefinedIconSetFormats (or TreeListView.PredefinedIconSetFormats) collection.

CFIconSetsMenu

Adding Rules Using Conditional Formatting Rules Manager

  1. Click the New Rule… in the Conditional Formatting Rules Manager.
  2. Select the Format all cells based on their values rule type in the invoked New Formatting Rule dialog.
  3. Select the Icon Sets format style.
  4. Specify the Type and Value fields. These options determine the conditional values on which cells/rows formatting is based.

    • To format cells/rows based on single column values, choose the Filed Name value in the Type field, and choose the required column field name in the Value field.
    • To specify a complex custom expression that returns a value based on several parameters (for example, several columns in a row), choose the Expression value in the Type field, and determine the required expression in the Value field using the Custom Condition Editor.
  5. Specify the Min Value and Max Value fields to determine the range of values used in formatting. These fields are optional. The range is calculated automatically based on maximum and minimum values from cell values by default.
  6. Specify the Icon Style field to define the visual appearance of the applied rule. You can set the rules to determine how to display icons.

CFIconSetsManager

See Also