How to: Apply Conditional Formatting to Grid Cells using the Date Occurring Format Condition

The Date Occurring format condition (FormatConditionDateOccuring) allows you to apply formatting to date-time values of a specific date and/or date interval relative to today.

This example demonstrates how to apply conditional formatting to Grid cells whose values fall into one of the predefined intervals.

´╗┐Imports DevExpress.DashboardCommon
Imports DevExpress.XtraEditors

Namespace Grid_DateOccurring
    Partial Public Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Public Sub New()
            Dim dashboard As New Dashboard()
            dashboardViewer1.Dashboard = dashboard
            Dim grid As GridDashboardItem =
                CType(dashboard.Items("gridDashboardItem1"), GridDashboardItem)
            Dim [date] As GridDimensionColumn = CType(grid.Columns(0), GridDimensionColumn)

            Dim dateOccuringRule As New GridItemFormatRule([date])
            Dim dateOccuringCondition As New FormatConditionDateOccuring()
            dateOccuringCondition.DateType = FilterDateType.MonthAgo1 Or FilterDateType.MonthAgo2
            dateOccuringCondition.StyleSettings =
                New AppearanceSettings(FormatConditionAppearanceType.PaleOrange)
            dateOccuringRule.Condition = dateOccuringCondition
            dateOccuringRule.ApplyToRow = True

        End Sub
    End Class
End Namespace

See Also