Skip to main content

Default Application Font

  • 4 minutes to read

By default, DevExpress Windows Forms controls use the Tahoma font (as specified by the static WindowsFormsSettings.FontBehavior property) of the default system font size. You can change the default font used by the controls with the following static properties.

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.

using DevExpress.XtraEditors;

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

Compared to DevExpress controls, standard Windows Forms controls use a different default font. The WindowsFormsSettings.FontBehavior property introduces several modes that help you force the DevExpress and standard controls to use the same font. Other FontBehavior modes allow you to apply one of the system fonts to DevExpress controls.

The DefaultFont and FontBehavior property values can be specified in a configuration file beforehand and then loaded at runtime using the WindowsFormsSettings.LoadApplicationSettings method. See this topic to learn more.

Fonts of Individual Controls

If you’d like to only change a certain control’s font, use the AppearanceObject.Font setting provided by the control’s appearance property (typically, appearance properties have the “Appearance” sub-string in their names). Make a note that some controls consist of multiple visual elements. These controls expose multiple appearance properties for all their elements. If this is the case, the font settings need to be changed across all the appearance properties provided by the control.

For instance, the following code shows how to change the font of all visual elements of a GridControl’s GridView, which consist of multiple elements.

using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Grid;

void SetGridFont(GridView view, Font font) {
    foreach(AppearanceObject ap in view.Appearance)
        ap.Font = font;
}

// Usage:
SetGridFont(gridView1, new Font("Courier New", 10));

The AppearanceObject objects also provide two special properties to adjust a control’s font.

Fonts of XtraBars Elements (Menus, Bars, Ribbon UI and Dock Panels)

As mentioned above, the default font of DevExpress menus, toolbars and popup menus can be customized using the static WindowsFormsSettings.DefaultMenuFont property. The default font of Ribbon items and dock panels is specified by the WindowsFormsSettings.DefaultFont property.

A more flexible alternative to specifying the default font of XtraBars Elements is using bar and dock controllers:

Bar and dock controllers expose the following appearance and font customization properties:

The following code changes the default font of main menus throughout the application using the default bar and dock controller.

DevExpress.XtraBars.BarAndDockingController.Default.AppearancesBar.MainMenu.Font = new Font("Tahoma", 14);

The Appearance… properties of bar and dock controllers take priority over the static WindowsFormsSettings.DefaultMenuFont and WindowsFormsSettings.DefaultFont properties.

Read the following topic to learn more: Look and Feel.