dashboard-devexpress-dot-dashboardwin-dot-dashboarddesigner-5c848b07.md
Allows you to customize the list of predefined periods in the Edit Periods dialog for the Range Filter dashboard item.
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
public event RangeFilterPredefinedDateTimePeriodsEventHandler RangeFilterPredefinedDateTimePeriods
Public Event RangeFilterPredefinedDateTimePeriods As RangeFilterPredefinedDateTimePeriodsEventHandler
The RangeFilterPredefinedDateTimePeriods event's data class is RangeFilterPredefinedDateTimePeriodsEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| FilterType | Gets the filter type specified in the Edit Periods dialog. |
| ItemComponentName | Gets the component name of the dashboard item for which the event was raised. |
| Periods | Provides access to a collection of predefined periods displayed in the Edit Periods dialog. |
This example shows how to use the DashboardDesigner.RangeFilterPredefinedDateTimePeriods event to customize a default list of predefined periods from the Edit Periods dialog. Note that this list is customized when filtering by year is applied in the dialog.
using DevExpress.DashboardCommon;
//...
private void dashboardDesigner_RangeFilterPredefinedDateTimePeriods(object sender, RangeFilterPredefinedDateTimePeriodsEventArgs e) {
if (e.ItemComponentName == "range" && e.FilterType == DateTimePeriodFilterType.Year) {
// Creates a new 'Last 4 Years' period.
FlowDateTimePeriodLimit startDate = new FlowDateTimePeriodLimit(DateTimeInterval.Year, -4);
FlowDateTimePeriodLimit endDate = new FlowDateTimePeriodLimit(DateTimeInterval.Year, 0);
DateTimePeriod period = new DateTimePeriod("Last 4 Years", startDate, endDate);
e.Periods.Insert(3, period);
// Removes the default 'Last Year' period.
period = e.Periods.FirstOrDefault(p => p.Name == DashboardWinLocalizer.GetString(DashboardWinStringId.PeriodLastYear));
e.Periods.Remove(period);
}
}
Imports DevExpress.DashboardCommon
'...
Private Sub dashboardDesigner_RangeFilterPredefinedDateTimePeriods(ByVal sender As Object, ByVal e As RangeFilterPredefinedDateTimePeriodsEventArgs)
If e.ItemComponentName = "range" AndAlso e.FilterType = DateTimePeriodFilterType.Year Then
' Creates a new 'Last 4 Years' period.
Dim startDate As New FlowDateTimePeriodLimit(DateTimeInterval.Year, -4)
Dim endDate As New FlowDateTimePeriodLimit(DateTimeInterval.Year, 0)
Dim period As New DateTimePeriod("Last 4 Years", startDate, endDate)
e.Periods.Insert(3, period)
' Removes the default 'Last Year' period.
period = e.Periods.FirstOrDefault(Function(p) p.Name = DashboardWinLocalizer.GetString(DashboardWinStringId.PeriodLastYear))
e.Periods.Remove(period)
End If
End Sub
See Also