zoukankan      html  css  js  c++  java
  • DevExpress动态换肤

    1.首先添加DevExpress.OfficeSkinsDevExpress.BonusSkins 两个引用。
    在Main()函数之前进行皮肤注册:

     1 static class Program 
     2 { 
     3 /// <summary> 
     4 /// 应用程序的主入口点。 
     5 /// </summary> 
     6 [STAThread] 
     7 static void Main() 
     8 { 
     9 DevExpress.UserSkins.BonusSkins.Register();//皮肤注册 
    10 DevExpress.UserSkins.OfficeSkins.Register(); 
    11 DevExpress.Skins.SkinManager.EnableFormSkins();//激活窗体皮肤,否则窗体还是操作系统默认主题风格 
    12 DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Blue"; 
    13 Application.EnableVisualStyles(); 
    14 Application.SetCompatibleTextRenderingDefault(false); 
    15 Application.Run(new XtraForm1()); 
    16 } 
    17 }

    2.添加一个父窗体,加一个全局静态DefaultLookAndFeel 成员控制皮肤,其他所有的窗体都继承该父窗体。

    public partial class frmBase: DevExpress.XtraEditors.XtraForm {
        private static DefaultLookAndFeel gLobalDefaultLookAndFeel = new DefaultLookAndFeel();
        public static DefaultLookAndFeel GLobalDefaultLookAndFeel {
            get {
                return frmBase.gLobalDefaultLookAndFeel;
            }
            set {
                frmBase.gLobalDefaultLookAndFeel = value;
            }
        }
        public frmBase() {
            InitializeComponent();
        }
    }
    

     3.添加一个控制皮肤的窗体frmSkin:

    public partial class frmSkin: DevExpress.XtraEditors.XtraForm {
        public frmSkin() {
            InitializeComponent();
        }
        private void frmSkin_Load(object sender, EventArgs e) {
            foreach(DevExpress.Skins.SkinContainer skinc in DevExpress.Skins.SkinManager.Default.Skins) {
                cboSkins.Properties.Items.Add(skinc.SkinName);
            }
        }
        private void cboSkins_SelectedIndexChanged(object sender, EventArgs e) {
            frmBase.GLobalDefaultLookAndFeel.LookAndFeel.SkinName = cboSkins.Text;
        }
        private void btnOK_Click(object sender, EventArgs e) {
            this.Close();
        }
    }
    

     

  • 相关阅读:
    ASP.NET Core 程序集注入(三)
    ASP.NET Core 程序集注入(二)
    ASP.NET Core 程序集注入(一)
    EFCore DbFirst从数据库生成实体类
    Notepad++实现代码格式化
    EF6/EFCore Code-First Timestamp SQL Server
    MySQL 实现 EF Code First TimeStamp/RowVersion 并发控制
    EntityFramework系列:MySql的RowVersion
    ansible常用命令大全
    python内置函数大全
  • 原文地址:https://www.cnblogs.com/sgll-290494386/p/3229890.html
Copyright © 2011-2022 走看看