Freigeben über


MonthCalendar Control Overview (Windows Forms)

The Windows Forms MonthCalendar control presents an intuitive graphical interface for users to view and set date information. The control displays a calendar: a grid containing the numbered days of the month, arranged in columns underneath the days of the week, with the selected range of dates highlighted. You can select a different month by clicking the arrow buttons on either side of the month caption. Unlike the similar DateTimePicker control, you can select more than one date with this control. For more information about the DateTimePicker control, see DateTimePicker Control (Windows Forms).

Configuring the MonthCalendar Control

The MonthCalendar control's appearance is highly configurable. By default, today's date is displayed as circled, and is also noted at the bottom of the grid. You can change this feature by setting the ShowToday and ShowTodayCircle properties to false. You can also add week numbers to the calendar by setting the ShowWeekNumbers property to true. By setting the CalendarDimensions property, you can have multiple months displayed horizontally and vertically. By default, Sunday is shown as the first day of the week, but any day can be designated using the FirstDayOfWeek property.

You can also set certain dates to be displayed in bold on a one-time basis, annually, or monthly, by adding DateTime objects to the BoldedDates, AnnuallyBoldedDates, and MonthlyBoldedDates properties. For more information, see How to: Display Specific Days in Bold with the Windows Forms MonthCalendar Control.

The key property of the MonthCalendar control is SelectionRange, the range of dates selected in the control. The SelectionRange value cannot exceed the maximum number of days that can be selected, set in the MaxSelectionCount property. The earliest and latest dates the user can select are determined by the MaxDate and MinDate properties.

See Also

Reference

MonthCalendar Class

Other Resources

MonthCalendar Control (Windows Forms)