如何修改全部DevExpress控件的字體


引用:https://www.devexpress.com/Support/Center/Question/Details/A2761

 

You can change the default font used by DevExpress WindowsForms controls with the following static properties:

DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont - Specifies the default font of controls (except menus and toolbars).
DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont - Specifies the default font used by menus and toolbars.
DevExpress.XtraEditors.WindowsFormsSettings.DefaultPrintFont - Specifies the default text font used when printing DevExpress controls.

 

可以通過修改以下靜態屬性:

DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont - 指定控件的默認字體,除了菜單(menu)和工具欄(toolbar)

DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont - 指定菜單(menu)和工具欄(toolbar)的默認字體

DevExpress.XtraEditors.WindowsFormsSettings.DefaultPrintFont - 指定打印控件(printing)的默認文本字體

[STAThread] static void Main() { DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = new Font("Courier New", 10); Application.Run(new Form1()); }

  

如果想改變某個控件的字體,需要通過設置AppearanceObject.Font屬性(通常,外觀屬性都有名為“Appearance”的字樣)

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM