Export (0) Print
Expand All

DateTimePicker.CalendarForeColor Property

Updated: September 2010

Gets or sets the foreground color of the calendar.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public Color CalendarForeColor { get; set; }

Property Value

Type: System.Drawing.Color
A Color that represents the foreground color of the calendar.

ExceptionCondition
ArgumentException

The value assigned is null.

When a DateTimePicker is created, this property is initially set equal to the ForeColor property 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();. For more information about visual styles, see How to: Enable Windows XP Visual Styles.

The following code example demonstrates how to initialize the CalendarForeColor property. This example creates a new DateTimePicker, adds it to the Controls collection, and then initializes its CalendarForeColor property to the Aqua constant.

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Date

History

Reason

September 2010

Added remarks about visual styles.

Customer feedback.

Community Additions

ADD
Show:
© 2014 Microsoft