Skip to main content

Predefined Ranges for the Range Filter in the WinForms Dashboard

  • 6 minutes to read

The Range Filter dashboard item allows you to add a number of predefined date-time periods that can be used to perform a selection (for instance, year-to-date or quarter-to-date).

RangeFilter_PredefinedRanges_Viewer

Add Predefined Periods

To add a period, use the following options:

  • Click the Options button (the BoundImageAttributeOptionsButton icon) next to the Argument placeholder.
  • Use the Edit Periods button in the Interactivity group on the Design ribbon tab of the Range Filter Tools contextual tab set.

This invokes the Edit Periods dialog.

RangeFilter_EditPeriodsDialog

To add the selected period, use the RangeFilter_AddPeriodIcon button or double-click this period.

RangeFilter_EditPeriodsDialog_AddPeriod

This period will be added to the right pane of the Edit Periods dialog. The following settings are available for the added period:

Caption
Specifies the caption corresponding to the period.
Period
Displays the date-time interval corresponding to the period.
Default
Allows you to use the selected period as the default selection in the Range Filter dashboard item.

If necessary, click the Edit button in the Edit Periods dialog to customize the selected period. This invokes the Period dialog:

RangeFilter_PeriodDialog

Note

Note that the Edit dialog above contains the displayed periods (Year, Quarter, Month, Day) if the group interval of the Range Filter argument is set to Day-Month-Year.

This dialog allows you to add the following periods:

Year

Period duration is measured in years.

  • Previous Year - Identifies the entire previous year.
  • This Year - Identifies the entire current year.
  • Next Year - Identifies the entire next year.
  • Last Years - Identifies a specific number of previous years. Use the Include current option to specify whether the period ends with the current year.
  • Next Years - Identifies a specific number of years to come. Use the Include current option to specify whether the period begins with the current year.
  • Year-to-date - A period from the beginning of the current year and up to the present day.
Quarter

Period duration is measured in quarters.

  • Previous Quarter - Identifies the entire previous quarter.
  • This Quarter - Identifies the entire current quarter.
  • Next Quarter - Identifies the entire next quarter.
  • Last Quarter - Identifies a specific number of previous quarters. Use the Include current option to specify whether the period ends with the current quarter.
  • Next Quarter - Identifies a specific number of following quarters. Use the Include current option to specify whether the period starts with the current quarter.
  • Quarter-to-date - A period from the beginning of the current quarter and up to the present day.
Month

Period duration is measured in months.

  • Previous Month - Identifies the entire previous month.
  • This Month - Identifies the entire current month.
  • Next Month - Identifies the entire next month.
  • Last Month - Identifies a specific number of previous months. Use the Include current option to specify whether the period ends with the current month.
  • Next Month - Identifies a specific number of the following months. Use the Include current option to specify whether the period starts with the current month.
  • Month-to-date - A period from the beginning of the current month and up to the present day.
Day

Period duration is measured in days.

  • Previous Day - Identifies the entire previous day.
  • This Day - Identifies the entire current day.
  • Next Day - Identifies the entire next day.
  • Last Day - Identifies a specific number of previous days. Use the Include current option to specify whether the period ends with the current day.
  • Next Day - Identifies a specific number of the following days. Use the Include current option to specify whether the period starts with the current day.
Custom
A custom period. See the next section for the details.

Add Custom Periods

A custom period allows you to specify a period with custom boundaries (Start point and End point).

RangeFilter_PeriodDialog_Custom

The following modes are available for the start and end boundaries:

None
The selection begins at the start/end of the visible range.
Fixed
Allows you to select a specific date value using the calendar. Use the Start/End Date option to set a value.
Flow
Allows you to select a relative date value. The Interval option specifies the interval between the current date and the required date. The Offset option allows you to set the number of such intervals. The Offset option can accept negative and positive values. Negative values correspond to dates before the current date, while positive values correspond to future dates.

Fixed Custom Period Examples

Name

Settings

2018

Start Point

  • Mode: Fixed
  • Start Date: 01/01/2018

End Point

  • Mode: Fixed
  • End Date: 12/31/2018

Q1 2017

Start Point

  • Mode: Fixed
  • Start Date: 01/01/2017

End Point

  • Mode: Fixed
  • End Date: 03/31/2018

Flow Custom Periods Examples

Name

Settings

6 Months

Start Point

  • Mode: Flow
  • Interval: Month
  • Offset: -5

End Point

  • Mode: None

Year to date

Start Point

  • Mode: Flow
  • Interval: Year
  • Offset: 0

End Point

  • Mode: Flow
  • Interval: Day
  • Offset: 0

Last Month

Start Point

  • Mode: Flow
  • Interval: Month
  • Offset: -1

End Point

  • Mode: Flow
  • Interval: Month
  • Offset: 0

If you set both start and end intervals with Flow Mode and 0 Offset configuration, the system subtracts 1 millisecond from the calculated end date to create a Start Point. This adjustment ensures that the Start Point is always strictly less than the End Point according to the selected end interval (year, month, week, and so on).

Example

This code snippet creates predefined DateTime periods for the Range Filter dashboard item.

using DevExpress.DashboardCommon;
// ...
rangeFilter.DateTimePeriods.AddRange(
    DateTimePeriod.CreateLastYear(),
    DateTimePeriod.CreateNextDays("Next 7 Days", 7),
    new DateTimePeriod
    { Name = "Month To Date",
        Start = new FlowDateTimePeriodLimit(DateTimeInterval.Month,0),
        End = new FlowDateTimePeriodLimit(DateTimeInterval.Day,1)
    },
    new DateTimePeriod
    { Name = "Jul-18-2018 - Jan-18-2019",
        Start = new FixedDateTimePeriodLimit(new DateTime(2018, 7, 18)),
        End = new FixedDateTimePeriodLimit(new DateTime(2019, 1, 18)) }
    );
// Specify the period selected when the control is initialized.
rangeFilter.DefaultDateTimePeriodName = "Year To Date";
See Also