Back to Devexpress

FormatConditionRangeSet Class

dashboard-devexpress-dot-dashboardcommon-a6defd17.md

latest7.6 KB
Original Source

FormatConditionRangeSet Class

A format condition used to apply formatting using value ranges and corresponding style settings.

Namespace : DevExpress.DashboardCommon

Assembly : DevExpress.Dashboard.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public class FormatConditionRangeSet :
    FormatConditionRangeBase
vb
Public Class FormatConditionRangeSet
    Inherits FormatConditionRangeBase

Remarks

Range conditions allow you to apply formatting using a predefined set of value ranges and corresponding style settings. You can use a predefined set of colors/icons to apply formatting or use custom ranges and corresponding icons/colors.

  1. To use a predefined set of colors/icons, pass the required FormatConditionRangeSetPredefinedType enumeration value to the FormatConditionRangeSet constructor or call the corresponding FormatConditionRangeSet.Generate method overload.

  2. To use a predefined set of colors/icons and custom range boundaries, do the following.

  3. To use custom range boundaries and the required style specified for each range, do the following.

Assign the resulting FormatConditionRangeSet object to the DashboardItemFormatRule.Condition property.

Example

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 Format Rule button to change the number of ranges, specify new range boundaries and customize icons corresponding to existing ranges.

View Example

csharp
using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;
using DevExpress.XtraEditors;

namespace Grid_FormatRules {
    public partial class IconRangeConditionForm : XtraForm {
        public IconRangeConditionForm() {
            InitializeComponent();
            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;

            grid.FormatRules.AddRange(rangeRule);
        }

        private void DashboardViewer1_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e)
        {
            DashboardToolbarItem itemUpdate = new DashboardToolbarItem((args) => UpdateFormatting()) {
                Caption = "Update Format Rule",
            };
            e.Items.Add(itemUpdate);
        }

        private void UpdateFormatting() {
            GridDashboardItem grid = 
                (GridDashboardItem)dashboardViewer1.Dashboard.Items["gridDashboardItem1"];
            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);
            rangeCondition.RangeSet.Add(range4);

            rangeRule.Condition = rangeCondition;
        }
    }
}
vb
Imports Microsoft.VisualBasic
Imports System
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWin
Imports DevExpress.XtraEditors

Namespace Grid_FormatRules
    Partial Public Class IconRangeConditionForm
        Inherits XtraForm
        Public Sub New()
            InitializeComponent()
            AddHandler dashboardViewer1.CustomizeDashboardTitle, AddressOf DashboardViewer1_CustomizeDashboardTitle
            Dim dashboard As New Dashboard()
            dashboard.LoadFromXml("..\..\Data\Dashboard.xml")
            dashboardViewer1.Dashboard = dashboard
            Dim grid As GridDashboardItem = CType(dashboard.Items("gridDashboardItem1"), GridDashboardItem)
            Dim extendedPrice As GridMeasureColumn = CType(grid.Columns(1), GridMeasureColumn)

            Dim rangeRule As New GridItemFormatRule(extendedPrice)
            Dim rangeCondition As New FormatConditionRangeSet(FormatConditionRangeSetPredefinedType.PositiveNegative3)
            rangeRule.Condition = rangeCondition

            grid.FormatRules.AddRange(rangeRule)
        End Sub

        Private Sub DashboardViewer1_CustomizeDashboardTitle(ByVal sender As Object, ByVal e As CustomizeDashboardTitleEventArgs)
            Dim itemUpdate As New DashboardToolbarItem(Sub(args) UpdateFormatting()) With {.Caption = "Update Format Rule"}
            e.Items.Add(itemUpdate)
        End Sub

        Private Sub UpdateFormatting()
            Dim grid As GridDashboardItem = CType(dashboardViewer1.Dashboard.Items("gridDashboardItem1"), GridDashboardItem)
            Dim rangeRule As GridItemFormatRule = grid.FormatRules(0)
            Dim rangeCondition As FormatConditionRangeSet = CType(rangeRule.Condition, FormatConditionRangeSet)
            Dim range3 As RangeInfo = rangeCondition.RangeSet(2)
            range3.Value = 50
            range3.StyleSettings = New IconSettings(FormatConditionIconType.DirectionalYellowUpInclineArrow)

            Dim range4 As New RangeInfo()
            range4.Value = 75
            range4.StyleSettings = New IconSettings(FormatConditionIconType.IndicatorCircledGreenCheck)
            rangeCondition.RangeSet.Add(range4)

            rangeRule.Condition = rangeCondition
        End Sub
    End Class
End Namespace

Inheritance

Object FormatConditionBase FormatConditionRangeBase FormatConditionRangeSet FormatConditionColorRangeBar

See Also

FormatConditionRangeSet Members

DevExpress.DashboardCommon Namespace