Export (0) Print
Expand All

DateTimePicker.CalendarMonthBackground Property

Gets or sets the background color of the calendar month.

[Visual Basic]
Public Property CalendarMonthBackground As Color
[C#]
public Color CalendarMonthBackground {get; set;}
[C++]
public: __property Color get_CalendarMonthBackground();
public: __property void set_CalendarMonthBackground(Color);
[JScript]
public function get CalendarMonthBackground() : Color;
public function set CalendarMonthBackground(Color);

Property Value

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

Exceptions

Exception Type Condition
ArgumentException The value assigned is a null reference (Nothing in Visual Basic).

Remarks

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

Example

[Visual Basic, C#, C++] The following 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.

[Visual Basic] 
Public Sub New()
   Dim dateTimePicker1 As New DateTimePicker()
   Controls.AddRange(New Control() {dateTimePicker1})
   dateTimePicker1.CalendarMonthBackground = Color.Aqua
End Sub 

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

[C++] 
public:
    MyClass() {
        DateTimePicker* dateTimePicker1 = new DateTimePicker();
        Control* myClassControls[] = {dateTimePicker1};
        Controls->AddRange(myClassControls); 
        dateTimePicker1->CalendarMonthBackground = Color::Aqua;
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DateTimePicker Class | DateTimePicker Members | System.Windows.Forms Namespace | DefaultMonthBackColor

Show:
© 2015 Microsoft