DateTimePicker.CalendarForeColor DateTimePicker.CalendarForeColor DateTimePicker.CalendarForeColor DateTimePicker.CalendarForeColor Property

定義

取得或設定月曆的前景色彩。Gets or sets the foreground color of the calendar.

public:
 property System::Drawing::Color CalendarForeColor { System::Drawing::Color get(); void set(System::Drawing::Color value); };
public System.Drawing.Color CalendarForeColor { get; set; }
member this.CalendarForeColor : System.Drawing.Color with get, set
Public Property CalendarForeColor As Color

屬性值

Color,表示月曆的前景色彩。A Color that represents the foreground color of the calendar.

例外狀況

指派值為 nullThe value assigned is null.

範例

下列程式碼範例示範如何初始化CalendarForeColor屬性。The following code example demonstrates how to initialize the CalendarForeColor property. 這個範例會建立新DateTimePicker的, 並將其Controls新增至集合, 然後將CalendarForeColor其屬性Aqua初始化為常數。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 = gcnew DateTimePicker;
      array<Control^>^ myClassControls = {dateTimePicker1};
      Controls->AddRange( myClassControls );
      dateTimePicker1->CalendarForeColor = Color::Aqua;
   }
public MyClass()
{
   DateTimePicker dateTimePicker1 = new DateTimePicker();
   Controls.AddRange(new Control[] {dateTimePicker1}); 
   dateTimePicker1.CalendarForeColor = Color.Aqua;
}
Public Sub New()
   Dim dateTimePicker1 As New DateTimePicker()
   Controls.AddRange(New Control() {dateTimePicker1})
   dateTimePicker1.CalendarForeColor = Color.Aqua
End Sub 

備註

建立時, 這個屬性最初會設定為等於ForeColor屬性值。 DateTimePickerWhen a DateTimePicker is created, this property is initially set equal to the ForeColor property value.

從 Windows Vista 開始, 視主題而定, 設定此屬性可能不會變更行事曆的外觀。Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. 例如, 如果 Windows 設定為使用 Aero 主題, 則設定此屬性不會有任何作用。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. 若要在 Visual Basic 中停用視覺化樣式, 請開啟 [專案設計工具], 然後取消選取 [啟用 XP 視覺化樣式] 核取方塊。To disable visual styles in Visual Basic, open the Project Designer and uncheck the Enable XP visual styles check box. 若要在中停C#用視覺化樣式, 請開啟Application.EnableVisualStyles();Program.cs 並將其批註。To disable visual styles in C#, open Program.cs and comment out Application.EnableVisualStyles();.

適用於

另請參閱