DateTimePicker.CalendarFont Property

Definition

Gets or sets the font style applied to the calendar.

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

Property Value

A Font that represents the font style applied to the calendar.

Examples

The following code example demonstrates how to initialize the CalendarFont property. This example creates a new DateTimePicker control, adds it to the Controls collection of a Form, and then initializes the CalendarFont property to a dynamically defined 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

Remarks

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();.

Applies to