使用DevExpress为自己的窗体实现换肤功能,应首先从DevExpress.XtraEditors.XtraForm继承窗体,然后在WinForm的入口文件除加入如下代码:
Application.EnableVisualStyles();
string file = string.Format("{0}\DevExpress.BonusSkins.v7.3.dll", Utilitys.Utility.GetExecutePath());
DevExpress.Skins.SkinManager.Default.RegisterAssembly(System.Reflection.Assembly.LoadFile(file));
file = string.Format("{0}\DevExpress.OfficeSkins.v7.3.dll", Utilitys.Utility.GetExecutePath());
DevExpress.Skins.SkinManager.Default.RegisterAssembly(System.Reflection.Assembly.LoadFile(file));
DevExpress.Skins.SkinManager.EnableFormSkins();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormLogin());
在form中可以根据SkinManager.Default.Skins获取整个皮肤集合,然后通过LookAndFeel.SetSkinStyle(皮肤名称);实现换肤。