DateTimePicker.CalendarFont Property


Gets or sets the font style applied to the calendar.

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

public Font CalendarFont { get; set; }

Property Value

Type: System.Drawing.Font

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

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

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 = new DateTimePicker();
   Controls.AddRange(new Control[] {dateTimePicker1}); 
   dateTimePicker1.CalendarFont = new Font("Courier New", 8.25F, FontStyle.Italic, GraphicsUnit.Point, ((Byte)(0)));

.NET Framework
Available since 1.1
Return to top