corelibraries-devexpress-dot-xtrareports-dot-parameters-dot-rangeparametereditoroptions-dot-registertimerange-x28-string-func-timeonly-func-timeonly-svgimage-x29.md
Appends an item to the list of predefined time ranges with a custom icon.
Namespace : DevExpress.XtraReports.Parameters
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public static void RegisterTimeRange(
string name,
Func<TimeOnly> getStart,
Func<TimeOnly> getEnd,
SvgImage image
)
Public Shared Sub RegisterTimeRange(
name As String,
getStart As Func(Of TimeOnly),
getEnd As Func(Of TimeOnly),
image As SvgImage
)
| Name | Type | Description |
|---|---|---|
| name | String |
The predefined time range’s name.
| | getStart | Func<TimeOnly> |
The function that returns the predefined time range’s start time.
The function that returns the predefined tim range’s end time.
| | image | SvgImage |
The SvgImage used as an icon for this time range in the time range parameter editor in Print Preview.
|
Use this method to append an item to the list of predefined time ranges stored in the PredefinedTimeRanges property. The appended predefined time range becomes available in the time range parameter editor in Print Preview.
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:
Note
This code is in effect for WinForms and WPF End-User Reporting Applications only.
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);
}
Imports DevExpress.XtraReports.Parameters
Imports DevExpress.XtraReports.Expressions
' ...
' Uncomment the line below if you want to clear the collection before adding new time ranges:
' RangeParameterEditorOptions.PredefinedTimeRanges.Clear()
Dim timeRangeNightShift As String = "Night Shift"
If Not RangeParameterEditorOptions.PredefinedTimeRanges.ContainsKey(timeRangeNightShift) Then
RangeParameterEditorOptions.RegisterTimeRange(timeRangeNightShift, Function() New TimeOnly(23, 0), Function() New TimeOnly(5, 0), SvgImage.FromFile("time.svg"))
End If
Dim timeRangeLastTwoHours As String = "Last Two Hours"
If Not RangeParameterEditorOptions.PredefinedTimeRanges.ContainsKey(timeRangeLastTwoHours) Then
Dim previousHour As TimeOnly = TimeOnly.FromDateTime(DateTime.Now.AddHours(-2))
Dim currentHour As TimeOnly = TimeOnly.FromDateTime(DateTime.Now.AddHours(0))
RangeParameterEditorOptions.RegisterTimeRange(timeRangeLastTwoHours, Function() previousHour, Function() currentHour)
End If
See Also
RegisterDateRange(String, Func<DateTime>, Func<DateTime>)
RangeParameterEditorOptions Class