1.项目中添加dev皮肤引用
2.在项目中注册皮肤,并且激活dev换肤功能。在应用程序主入口点main函数中加入下面代码
DevExpress.UserSkins.OfficeSkins.Register();
DevExpress.UserSkins.BonusSkins.Register();
DevExpress.Skins.SkinManager.EnableFormSkins();
DevExpress.LookAndFeel.LookAndFeelHelper.ForceDefaultLookAndFeelChanged();
如果要使mdi子窗体也实现换肤功能,添加下面代码
DevExpress.Skins.SkinManager.EnableMdiFormSkins();
3.新建一个xtrform窗体。拖入defaultLookAndFeel控件
4.添加一个comboBoxEdit控件,将dev控件的皮肤样式显示出来,在comboBoxEdit的comboBoxEdit1_EditValueChanged事件中写换肤代码,后台代码如下
private void XtraForm1_Load(object sender, EventArgs e)
{
foreach (DevExpress.Skins.SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins)
comboBoxEdit1.Properties.Items.Add(skin.SkinName);
}
private void comboBoxEdit1_EditValueChanged(object sender, EventArgs e)
{
defaultLookAndFeel1.LookAndFeel.SkinName = comboBoxEdit1.EditValue.ToString();
}
5.运行程序,选择皮肤,就会实现换肤功能了。