DateTimePicker.CalendarMonthBackground Property

Definition

Gets or sets the background color of the calendar month.

C#
public System.Drawing.Color CalendarMonthBackground { get; set; }

Property Value

A Color that represents the background color of the calendar month.

Exceptions

The value assigned is null.

Examples

The following code example demonstrates how to initialize the CalendarMonthBackground property. After creating a DateTimePicker and adding it to a Form, the example initializes the CalendarMonthBackground property to a Color constant.

C#
public MyClass()
{
   DateTimePicker dateTimePicker1 = new DateTimePicker();
   Controls.AddRange(new Control[] {dateTimePicker1}); 
   dateTimePicker1.CalendarMonthBackground = Color.Aqua;
}

Remarks

When a DateTimePicker is created, this property is initially set equal to the DefaultMonthBackColor field value.

Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the Enable XP visual styles check box. To disable visual styles in C#, open Program.cs and comment out Application.EnableVisualStyles();.

Applies to

Produkt Versioner
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also