# Selection

Read the topic to know more about DateEdit control for WinForms.

## Content



The **CalendarView** control lets you select multiple dates, specific dates, date ranges, weeks etc. CalendarView also lets you set rules to determine the selection behavior while navigating between months. The sub-sections below explains the selection behavior using CalendarView in detail.

## Multiple Selection

When selecting multiple days, **CalendarView** supports contiguous or non-contiguous selection. Contiguous selection lets you select adjacent days, while keeping the SHIFT key pressed. On the other hand, non-contiguous selection lets you select separate days, while keeping the CTRL key pressed.

The image below depicts the CalendarView control when the MaxSelectionCount is set to 3:

![](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/maximum-selection.png)

## Selecting Specific Dates

Let's say, you want to display specific dates to the end-user in the **CalendarView**. For this purpose, the control allows you to set particular dates using the SelectedDates property in the control.

![](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/threedates-selectedcalendar.png)

The code snippet below shows how to use **SelectedDates** property to display specific dates by setting it to a [DateTime](https://docs.microsoft.com/en-us/dotnet/api/system.datetime?view=net-5.0) array:

```csharp
// Add selected dates
calendarView.SelectedDates = new DateTime[]
{
    new DateTime(2021, 03, 15),
    new DateTime(2021, 03, 16),
    new DateTime(2021, 03, 17)
};
```

## Set Selectable Date Range

**CalendarView** lets you customize the calendar UI to show a limited set of days in the visible calendar month and restrict the selection to the specified range of dates from the calendar, so that the dates outside the range are disabled for selection.

Setting a minimum date helps you to restrict selecting the date value that is set less than the specified value. Likewise, setting a maximum date helps you to restrict selecting the date value that is set greater than the specified value.

By default, the maximum and the minimum allowable dates are 12/31/9999 and 01/01/0001 respectively. To specify the maximum and minimum allowable dates, set the [MaxDate](/componentone/docs/win/online-calendar/) and the [MinDate](/componentone/docs/win/online-calendar/) properties respectively.

In the image below, the minimum and maximum dates are set to 15/04/2021 and 27/04/2021 respectively. As you can observe, all other date values outside this range are disabled, and only a particular date range can be selected.

![](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/daterange-calendarview.png)

The code snippet below shows how to set a date range using the **MaxDate** and **MinDate** properties.

```csharp
// Set a maximum date
calendarView.MaxDate = new DateTime(2021, 4, 27);
// Set a minimum date
calendarView.MinDate = new DateTime(2021, 4, 15);
```

## Week Number Selector

**CalendarView** provides week numbers that appear in a vertical list alongside each week towards the left in the calendar UI. As there are a total of 52 weeks in a calendar year, the CalendarView control displays 1 to 52 week numbers. The week number selector allows selecting days in a specific week in a single click. The number of days selected depends on the **MaxSelectionCount** property. For example let's say, you want to select all days in a week. For this, you have to set the **MaxSelectionCount** property greater than or equal to 7.

![](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/week-selection.png)

## Selection Rule

CalendarView lets you define selection behavior while navigating between months in a Calendar UI. For this, **C1CalendarView** class provides the **SelectionRule** property that sets four types of rules for automatic selection of dates while navigating from one month to the other.

The **SelectionRule** property accesses the **SelectionRule** enumeration to set the rule in which dates are automatically selected while navigating between consecutive months.

The following table list the four types of selection rules provided by the SelectionRule property.

| **Selection Rule** | **GIFs** | **Description** |
| --- | --- | --- |
| EnumerationFirstDay |   ![](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/enumeration-firstday.gif)   | Selects first days of the month while navigating. |
| EnumerationLastDays |   ![](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/enumeration-lastday.gif)   | Selects last days of the month while navigating. |
| EnumerationNone |   ![](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/enumeration-none.gif)   | Keeps selection while navigating. |
| EnumerationSameDay |   ![](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/enumeration-sameday.gif)   | Moves selection to the same day as the previous month while navigating. |

The code snippet depicts how to programmatically set the **SelectionRule** as '**EnumerationSameDay**'.

```csharp
// Sets selection behavior during month navigation
calendarView.SelectionRule = C1.CalendarView.SelectionRule.EnumerationSameDay;
```