# Behavior

From setting specific datetimes to disabling certain dates, DateEdit has all the features essential for a perfect datepicker! Read the topic to know more about DateEdit control for WinForms.

## Content



The C1DateEdit class offers several properties that determines the behavior of the DateEdit control. Users can add a DateEdit control to a form, set a specific date or time, set minimum and maximum dates, disable dates, and show or hide Today/Clear buttons in the calendar dropdown.

Let's explore the DateEdit behavior in detail.

### Set specific date and time

Let's say, you want to display a specific date to the end-user in the DateEdit. For this purpose, the control allows you to set a particular date using the [Value](/componentone/docs/win/online-calendar/) property in the control.

![DateEdit with calendar UI showing specific date](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/set-specificdate-dateedit.png)

The code snippet below shows how to set a specific date:

```csharp
// Set the Value property to a date value.
dateEdit.Value = new DateTime(2021, 03, 03);
```

Let's say, you want to display a specific time with the date in the control. For this purpose, you can again use the Value property.

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

```csharp
// Set the Value property to a date and time value
dateEdit.Value = new DateTime(2021, 03, 15, 10, 0, 0);
```

### Set date range

DateEdit lets you to customize the dropdown calendar 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.

You can specify minimum and maximum dates to prevent users from selecting a date and time in a particular range. Setting a minimum date helps you to restrict selecting the date value that is set less than the specific value. Likewise, setting a maximum date helps you to restrict selecting the date value that is set greater than the specific value.

In the image below, the minimum and maximum date has been set (to 01/03/2021 and 25/03/2021 respectively). As you can observe, all other date values outside this range are disabled, and only a particular date range can be selected.

![DateEdit with calendar ui showing minimum and maximum range of dates](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/min-max-datedit-range.png)

Users can set the minimum and maximum date values in the calendar dropdown of DateEdit control, by using the [MinDate](/componentone/docs/win/online-calendar/) and [MaxDate](/componentone/docs/win/online-calendar/) properties.

```csharp
// Set a minimum date
dateEdit.Calendar.MinDate = new DateTime(2021, 3, 1);
// Set a maximum date
dateEdit.Calendar.MaxDate = new DateTime(2021, 3, 25);
```

### Disable dates

Consider a scenario, where you want to disable certain dates in the calendar dropdown. The DateEdit control gives a choice to the users to disable certain dates by using the [DisabledDates](/componentone/docs/win/online-calendar/) property.

In the image below, certain dates have been disabled in the control, such as 03/03/2021, 05/03/2021, 10/03/2021, 15/03/2021, 16/03/2021 and 17/03/2021.

![DateEdit with calendar UI with disabled dates](https://cdn.mescius.io/document-site-files/images/1b33a1f1-17e3-4593-a233-97e8b8ff7610/images/disabledate-dateditcontrol.png)

The following code shows how to disable dates:

```csharp
// Set array of dates which need to be disabled
 DateTime[] dateTimes = new DateTime[]
{
    new DateTime(2021, 03, 03),
    new DateTime(2021, 03, 05),
    new DateTime(2021, 03, 10),
    new DateTime(2021, 03, 15),
    new DateTime(2021, 03, 16),
    new DateTime(2021, 03, 17),
    // etc
};
// Add the DisabledDates property to C1DateEditcontrol to disable certain dates
 dateEdit.Calendar.DisabledDates = dateTimes;
```

### Show or hide Today and Clear buttons

By default, DateEdit comes with a **Today** button and **Clear** button functionality. The **Today** button shows the current date to the end-user, while the **Clear** button clears the value in the DateEdit editor. The control lets you show or hide **Today** and **Clear** buttons in the calendar dropdown of DateEdit using the [ShowToday](/componentone/docs/win/online-calendar/) and [ShowClearButton](/componentone/docs/win/online-calendar/) properties.

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

The following code shows how to hide Today and Clear buttons:

```csharp
// Hide Today button
dateEdit.Calendar.ShowToday = false;
// Hide Clear button
dateEdit.Calendar.ShowClearButton = false;
```