How to: Apply Conditional Formatting to Grid Cells using the Icon Ranges Format Condition

  • 2 min to read

Range conditions (FormatConditionRangeSet) allow you to use predefined or custom sets of icons/colors to apply conditional formatting to different ranges of values.

This example shows how to apply conditional formatting to Grid cells using a predefined set of icons. Click the Update Formatting button to change the number of ranges, specify new range boundaries and customize icons corresponding to existing ranges.


The complete sample project How to Apply the Icon Ranges Conditional Formatting to Grid Cells is available in the DevExpress Examples repository.

using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;

namespace Grid_IconRangeCondition {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        public Form1() {
            dashboardViewer1.CustomizeDashboardTitle += DashboardViewer1_CustomizeDashboardTitle;
            Dashboard dashboard = new Dashboard(); dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");
            dashboardViewer1.Dashboard = dashboard;
            GridDashboardItem grid = (GridDashboardItem)dashboard.Items["gridDashboardItem1"];
            GridMeasureColumn extendedPrice = (GridMeasureColumn)grid.Columns[1];

            GridItemFormatRule rangeRule = new GridItemFormatRule(extendedPrice);
            FormatConditionRangeSet rangeCondition = 
                new FormatConditionRangeSet(FormatConditionRangeSetPredefinedType.PositiveNegative3);
            rangeRule.Condition = rangeCondition;


        private void DashboardViewer1_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e)
            DashboardToolbarItem itemUpdate = new DashboardToolbarItem(
                (args) => UpdateFormatting())
                Caption = "Update Formatting",

        private void UpdateFormatting() {
            GridDashboardItem grid = 
            GridItemFormatRule rangeRule = grid.FormatRules[0];
            FormatConditionRangeSet rangeCondition = (FormatConditionRangeSet)rangeRule.Condition;
            RangeInfo range3 = rangeCondition.RangeSet[2];
            range3.Value = 50;
            range3.StyleSettings = 
                new IconSettings(FormatConditionIconType.DirectionalYellowUpInclineArrow);

            RangeInfo range4 = new RangeInfo();
            range4.Value = 75;
            range4.StyleSettings = 
                new IconSettings(FormatConditionIconType.IndicatorCircledGreenCheck);

            rangeRule.Condition = rangeCondition;
See Also