WindowsFormsSettings.DefaultFont Property

Gets or sets the default font for DevExpress controls (except menus and toolbars). This is a static property.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.Utils.v20.1.dll

Declaration

public static Font DefaultFont { get; set; }
Public Shared Property DefaultFont As Font

Property Value

Type Description
Font

A Font object which is the default font for controls. The default value is the Tahoma font.

Remarks

The DefaultFont property's value is used to initialize default fonts for the DevExpress controls that support the appearance mechanism (i.e., for the controls that provide properties of the WindowsFormsSettings type used to customize control appearance settings).

We highly recommend that you use the DevExpress Project Settings dialog to change the default font for DevExpress controls.

Project Settings Page

If you need to change the default font in code, do that prior to running the main application form (see the sample below). Once a default font is set, do not change it when the application is running.


[STAThread]
static void Main() {
    WindowsFormsSettings.DefaultFont = new System.Drawing.Font("Arial", 12);
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}

If the Tahoma font is not installed on the user's computer, the default value for the DefaultFont property is determined by the DEFAULT_GUI_FONT object. The DEFAULT_GUI_FONT is the default font used by user interface objects, such as menus and dialog boxes.

When changing the DefaultFont property, you may experience control auto-height issues for BaseEdit descendants when they are anchored to the right edge of their container (i.e., when the Anchor property includes the Right flag). To resolve these issues, we suggest that you manually set the AutoSize properties to true for these controls.

NOTE

You can also specify fonts for controls using the application settings architecture. This allows you to separate application settings from the application code and provide consistency between design and run time. See the WindowsFormsSettings.LoadApplicationSettings method for details.

See Default Application Font for more information.

See Also