DateTimePicker.CalendarMonthBackground 屬性

定義

取得或設定月曆月份的背景色彩。

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

屬性值

Color,表示月曆月份的背景色彩。

例外狀況

指派值為 null

範例

下列程式碼範例示範如何初始化 CalendarMonthBackground 屬性。 建立 DateTimePicker 並將其新增至 Form 之後,此範例會將 CalendarMonthBackground 屬性初始化為 Color 常數。

public:
   MyClass()
   {
      DateTimePicker^ dateTimePicker1 = gcnew DateTimePicker;
      array<Control^>^ myClassControls = {dateTimePicker1};
      Controls->AddRange( myClassControls );
      dateTimePicker1->CalendarMonthBackground = Color::Aqua;
   }
public MyClass()
{
   DateTimePicker dateTimePicker1 = new DateTimePicker();
   Controls.AddRange(new Control[] {dateTimePicker1}); 
   dateTimePicker1.CalendarMonthBackground = Color.Aqua;
}
Public Sub New()
   Dim dateTimePicker1 As New DateTimePicker()
   Controls.AddRange(New Control() {dateTimePicker1})
   dateTimePicker1.CalendarMonthBackground = Color.Aqua
End Sub

備註

DateTimePicker建立 時,這個屬性一開始會設定為 DefaultMonthBackColor 等於域值。

從 Windows Vista 開始,視主題而定,設定此屬性可能不會變更行事曆的外觀。 例如,如果 Windows 設定為使用[空中] 主題,則設定此屬性不會有任何作用。 這是因為更新版本的行事曆會以從目前的作業系統主題在執行時間衍生的外觀來轉譯。 如果您想要使用此屬性並啟用舊版行事曆,您可以停用應用程式的視覺化樣式。 停用視覺化樣式可能會影響應用程式中其他控制項的外觀和行為。 若要停用 Visual Basic 中的視覺化樣式,請開啟 [專案Designer,然後取消核取 [啟用 XP 視覺效果樣式] 核取方塊。 若要停用 C# 中的視覺化樣式,請開啟 Program.cs 並批註化 Application.EnableVisualStyles();

適用於

另請參閱