DateTimePicker.CalendarFont 屬性

定義

取得或設定套用至月曆的字型樣式。

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

屬性值

Font

Font,表示套用至月曆的字型樣式。

範例

下列程式碼範例示範如何初始化 CalendarFont 屬性。 這個範例會建立新的 DateTimePicker 控制項,並將它加入 至 ControlsForm 集合,然後將 屬性初始化 CalendarFont 為動態定義的 Font

public:
   MyClass()
   {
      // Create a new DateTimePicker.
      DateTimePicker^ dateTimePicker1 = gcnew DateTimePicker;
      array<Control^>^ myClassControls = {dateTimePicker1};
      Controls->AddRange( myClassControls );
      dateTimePicker1->CalendarFont = gcnew System::Drawing::Font(
         "Courier New", 8.25F, FontStyle::Italic, GraphicsUnit::Point, ((Byte)(0)) );
   }
public MyClass()
{
   // Create a new DateTimePicker.
   DateTimePicker dateTimePicker1 = new DateTimePicker();
   Controls.AddRange(new Control[] {dateTimePicker1}); 
   dateTimePicker1.CalendarFont = new Font("Courier New", 8.25F, FontStyle.Italic, GraphicsUnit.Point, ((Byte)(0)));
}
Public Sub New()
   ' Create a new DateTimePicker.
   Dim dateTimePicker1 As New DateTimePicker()
   Controls.AddRange(New Control() {dateTimePicker1})
   dateTimePicker1.CalendarFont = New Font("Courier New", 8.25F, FontStyle.Italic, GraphicsUnit.Point, CType(0, [Byte]))
End Sub

備註

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

適用於