|
47 | 47 | <format type="text/markdown"><![CDATA[
|
48 | 48 |
|
49 | 49 | ## Remarks
|
50 |
| - The <xref:System.Windows.Forms.MonthCalendar> control allows the user to select a date using a visual display. You can limit the date and times that can be selected by setting the <xref:System.Windows.Forms.MonthCalendar.MinDate%2A> and <xref:System.Windows.Forms.MonthCalendar.MaxDate%2A> properties. |
| 50 | + The `MonthCalendar` control allows the user to select a date using a visual display. You can limit the date and times that can be selected by setting the <xref:System.Windows.Forms.MonthCalendar.MinDate%2A> and <xref:System.Windows.Forms.MonthCalendar.MaxDate%2A> properties. |
51 | 51 |
|
52 | 52 | You can change the look of the calendar portion of the control by setting the <xref:System.Windows.Forms.Control.ForeColor%2A>, <xref:System.Windows.Forms.Control.Font%2A>, <xref:System.Windows.Forms.MonthCalendar.TitleBackColor%2A>, <xref:System.Windows.Forms.MonthCalendar.TitleForeColor%2A>, <xref:System.Windows.Forms.MonthCalendar.TrailingForeColor%2A>, and <xref:System.Windows.Forms.Control.BackColor%2A> properties.
|
53 | 53 |
|
54 | 54 | > [!NOTE]
|
55 |
| -> The <xref:System.Windows.Forms.DateTimePicker> control only supports Gregorian calendars. |
| 55 | +> The `MonthCalendar` control only supports Gregorian calendars. |
56 | 56 |
|
57 |
| -> [!NOTE] |
58 |
| -> The <xref:System.Windows.Forms.DateTimePicker> control only supports Gregorian calendars. |
59 |
| - |
60 |
| - The <xref:System.Windows.Forms.MonthCalendar> control is drawn by the operating system, so the <xref:System.Windows.Forms.MonthCalendar.Paint> event is never raised. If you need to provide a customized look to the <xref:System.Windows.Forms.MonthCalendar> control, you should override the <xref:System.Windows.Forms.Control.OnPrint%2A> method, call the base implementation of <xref:System.Windows.Forms.Control.OnPrint%2A>, and then perform custom painting. |
| 57 | + The `MonthCalendar` control is drawn by the operating system, so the <xref:System.Windows.Forms.MonthCalendar.Paint> event is never raised. If you need to provide a customized look to the <xref:System.Windows.Forms.MonthCalendar> control, you should override the <xref:System.Windows.Forms.Control.OnPrint%2A> method, call the base implementation of <xref:System.Windows.Forms.Control.OnPrint%2A>, and then perform custom painting. |
61 | 58 |
|
62 | 59 | If you need custom date formatting and a selection limited to just one date, you might consider using a <xref:System.Windows.Forms.DateTimePicker> control instead of a <xref:System.Windows.Forms.MonthCalendar>. Using the <xref:System.Windows.Forms.DateTimePicker> eliminates much of the need for validating date/time values.
|
63 | 60 |
|
|
66 | 63 |
|
67 | 64 |
|
68 | 65 | ## Examples
|
69 |
| - The following code example displays a form containing a <xref:System.Windows.Forms.MonthCalendar> control that displays one calendar year. The example demonstrates setting the <xref:System.Windows.Forms.Control.BackColor%2A>, <xref:System.Windows.Forms.Control.ForeColor%2A>, <xref:System.Windows.Forms.MonthCalendar.TitleBackColor%2A>, <xref:System.Windows.Forms.MonthCalendar.TitleForeColor%2A>, <xref:System.Windows.Forms.MonthCalendar.CalendarDimensions%2A>, and <xref:System.Windows.Forms.MonthCalendar.TrailingForeColor%2A> properties to customize the look of the calendar control. Other properties such as <xref:System.Windows.Forms.MonthCalendar.AnnuallyBoldedDates%2A>, <xref:System.Windows.Forms.MonthCalendar.BoldedDates%2A>, and <xref:System.Windows.Forms.MonthCalendar.MonthlyBoldedDates%2A> are set to customize which dates are bold. The example also sets the <xref:System.Windows.Forms.MonthCalendar.FirstDayOfWeek%2A>, <xref:System.Windows.Forms.MonthCalendar.MaxDate%2A>, <xref:System.Windows.Forms.MonthCalendar.MinDate%2A>, and <xref:System.Windows.Forms.MonthCalendar.MaxSelectionCount%2A> properties to change the calendar format. The <xref:System.Windows.Forms.MonthCalendar.DateSelected> and <xref:System.Windows.Forms.MonthCalendar.DateChanged> events are also handled and their status is displayed on the form. |
| 66 | + The following code example displays a form containing a `MonthCalendar` control that displays one calendar year. The example demonstrates setting the <xref:System.Windows.Forms.Control.BackColor%2A>, <xref:System.Windows.Forms.Control.ForeColor%2A>, <xref:System.Windows.Forms.MonthCalendar.TitleBackColor%2A>, <xref:System.Windows.Forms.MonthCalendar.TitleForeColor%2A>, <xref:System.Windows.Forms.MonthCalendar.CalendarDimensions%2A>, and <xref:System.Windows.Forms.MonthCalendar.TrailingForeColor%2A> properties to customize the look of the calendar control. Other properties such as <xref:System.Windows.Forms.MonthCalendar.AnnuallyBoldedDates%2A>, <xref:System.Windows.Forms.MonthCalendar.BoldedDates%2A>, and <xref:System.Windows.Forms.MonthCalendar.MonthlyBoldedDates%2A> are set to customize which dates are bold. The example also sets the <xref:System.Windows.Forms.MonthCalendar.FirstDayOfWeek%2A>, <xref:System.Windows.Forms.MonthCalendar.MaxDate%2A>, <xref:System.Windows.Forms.MonthCalendar.MinDate%2A>, and <xref:System.Windows.Forms.MonthCalendar.MaxSelectionCount%2A> properties to change the calendar format. The <xref:System.Windows.Forms.MonthCalendar.DateSelected> and <xref:System.Windows.Forms.MonthCalendar.DateChanged> events are also handled and their status is displayed on the form. |
70 | 67 |
|
71 | 68 | [!code-cpp[System.Windows.Forms.MonthCalendar#1](~/samples/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.MonthCalendar/CPP/monthcalendar.cpp#1)]
|
72 | 69 | [!code-csharp[System.Windows.Forms.MonthCalendar#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.MonthCalendar/CS/monthcalendar.cs#1)]
|
|
0 commit comments