$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Calendar Controls for WinForms UI Tutorial
Add days to the calendar in C# at design time and iterate and display the dates in C# at runtime
Home > WinForms UI Controls > User Manual > Calendar Getting Started in C#

Add Calendar - WinForms Calendar Controls

The Calendar Control supports not only all features of the standard Month Calendar control in the Visual Studio toolbox, like first day of week, special days, show today, show week numbers, and hide week numbers, but also additional features that the standard Calendar control do not support. In this tutorial of creating calendar in C# for Windows Forms Applications, we will show how to add selected and special days to the calendar at design time, then iterating and displaying those dates at runtime.

How to add selected and special days to the calendar at design time

  1. Create a new form in your Windows Forms Application
  2. Drag and drop a Calendar control to the form.
  3. Set the property value of EnableMultipleSelect to true.
  4. Drag and drop a List Control and Button to the form in your WinForms Application.
  5. Click the ellipses for the SelectedDates property of the Calendar in the Properties Window.
  6. Click the Add button to append a new selected date to the collection.
  7. In the Value property for the date, choose today from the drop down calendar.
  8. Add two more dates. Set the property of Value to the two days following today.
  9. Click the ellipses for the Special Days property of the Calendar in the Properties Window.
  10. Click the Add button to append a new Calendar Day to the collection.
  11. Configure the property of Date for the special day to the last day of the month.
  12. Set the property of Disabled to true, and set the property of Recurring to DayInMonth.
  13. Double click the Button item in the designer, and add the below C# code to the Click event handler.
  14. The C# code will iterate and list results for the SelectedDates and SpecialDays collections.
The following C# code illustrate how to iterate the SelectedDates and SpecialDates collections:

private void button1_Click(object sender, EventArgs e)
{
foreach (DateTime dateTime in Calendar1.SelectedDates)
{
listControl1.Items.Add(
new listDataItem("Selected: " + dateTime.ToShortDateString()));
}
foreach (calendarDay day in Calendar1.SpecialDays)
{
listControl1.Items.Add(
new listDataItem("Special: " + day.Date.ToShortDateString()));
}
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls