windowsforms-devexpress-dot-xtraeditors-dot-dateedit-82f1dd83.md
Gets or sets selected date ranges.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[Browsable(false)]
public DateRangeCollection SelectedRanges { get; }
<Browsable(False)>
Public ReadOnly Property SelectedRanges As DateRangeCollection
| Type | Description |
|---|---|
| DevExpress.XtraEditors.Controls.DateRangeCollection |
A collection of selected date ranges.
|
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))
});
Imports DevExpress.XtraEditors.Controls
Imports 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));
Dim isSelected As Boolean = calendarControl1.SelectedRanges.IsDateSelected(DateTime.Today.AddDays(5))
See Also