DateEdit.SelectedRanges Property
Gets or sets selected date ranges.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v25.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Property Value
Type | Description |
---|---|
DevExpress.XtraEditors.Controls.DateRangeCollection | A collection of selected date ranges. |
Remarks
The SelectedRanges
collection contains DevExpress.XtraEditors.Controls.DateRange
objects. The DateRange
object includes dates that are EQUAL OR GREATER THAN the DateRange.StartDate
and LESS THAN the DateRange.EndDate
.
This following code snippet does the following:
- Activates multiple date selection for a calendar control.
- Selects two date ranges: one in the past (10 to 5 days ago) and one in the future (4 to 10 days from today).
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
// Enable multiple date selection in the calendar control.
calendarControl1.SelectionMode = CalendarSelectionMode.Multiple;
// Add two date ranges to the calendar's selected ranges:
// - First range: from 10 days ago to 5 days ago.
// - Second range: from 4 days in the future to 10 days in the future.
calendarControl1.SelectedRanges.AddRange(new DateRange[] {
new DateRange(DateTime.Today.AddDays(-10), DateTime.Today.AddDays(-5)),
new DateRange(DateTime.Today.AddDays(4), DateTime.Today.AddDays(10))
});
The image blow illustrates the result:
Use the IsDateSelected
method to check whether a specific date is selected:
bool isSelected = calendarControl1.SelectedRanges.IsDateSelected(DateTime.Today.AddDays(5));
See Also