RangeParameterEditorOptions Class
A static class that provides access to the list of predefined ranges that are displayed in the date or time range parameter‘s editor in Print Preview.
Namespace: DevExpress.XtraReports.Parameters
Assembly: DevExpress.Printing.v25.1.Core.dll
NuGet Package: DevExpress.Printing.Core
Declaration
Remarks
Date and time range parameters are used in reporting applications.
A range parameter editor displays a list of predefined ranges that users can select from:
- Predefined ranges for “Date” and “Date and Time” range parameters
- Predefined ranges for “Time” range parameters
Use the RangeParameterEditorOptions
static class in WinForms and WPF applications to customize the list of predefined value ranges. The following members allow you to adjust the predefined ranges:
- PredefinedDateRanges
- Stores the list of predefined date ranges available in the date range parameter editor in Print Preview.
- RegisterDateRange(String, Func<DateTime>, Func<DateTime>)
- Appends an item to the list of predefined date ranges.
- PredefinedTimeRanges
- Stores the list of predefined time ranges available in the time range parameter editor in Print Preview.
- RegisterTimeRange(String, Func<TimeOnly>, Func<TimeOnly>)
- Appends an item to the list of predefined time ranges with a default icon.
- RegisterTimeRange(String, Func<TimeOnly>, Func<TimeOnly>, SvgImage)
- Appends an item to the list of predefined time ranges with a custom icon.
Examples
The following example modifies the available date ranges displayed in Print Preview. The code clears the list of predefined date ranges and adds the September and October predefined ranges to the parameter’s editor for a date range parameter:
using DevExpress.XtraReports.Parameters;
// ...
// Remove all predefined ranges and add two new date ranges.
RangeParameterEditorOptions.PredefinedDateRanges.Clear();
RangeParameterEditorOptions.RegisterDateRange("September", () => new DateTime(2019,9,1), () => new DateTime(2019,9,30));
RangeParameterEditorOptions.RegisterDateRange("October", () => new DateTime(2019,10,1), () => new DateTime(2019,10,31));
Refer to the following example that creates a date range parameter in code and uses this parameter to filter the report’s data:
The following example modifies the available time ranges displayed in Print Preview. The code adds the NightShift and Last Two Hours predefined ranges to the parameter’s editor for a time range parameter:
using DevExpress.XtraReports.Parameters;
// ...
// Uncomment the line below if you want to clear the collection before adding new time ranges:
//RangeParameterEditorOptions.PredefinedTimeRanges.Clear();
string timeRangeNightShift = "Night Shift";
if (!RangeParameterEditorOptions.PredefinedTimeRanges.ContainsKey(timeRangeNightShift)) {
RangeParameterEditorOptions.RegisterTimeRange(timeRangeNightShift,() => new TimeOnly(23,0),() => new TimeOnly(5,0),SvgImage.FromFile("time.svg"));
}
string timeRangeLastTwoHours = "Last Two Hours";
if (!RangeParameterEditorOptions.PredefinedTimeRanges.ContainsKey(timeRangeLastTwoHours)) {
TimeOnly previousHour = TimeOnly.FromDateTime(DateTime.Now.AddHours(-2));
TimeOnly currentHour = TimeOnly.FromDateTime(DateTime.Now.AddHours(0));
RangeParameterEditorOptions.RegisterTimeRange(timeRangeLastTwoHours, () => previousHour,() => currentHour);
}