标签:winform 换肤 devexpress
winform换肤流程如下:
(1)程序入口,添加以下代码:
//换肤 private void Skinjsj() { DevExpress.UserSkins.BonusSkins.Register(); DevExpress.UserSkins.OfficeSkins.Register(); DevExpress.Skins.SkinManager.EnableFormSkins(); FrmSkin f = new FrmSkin(this); f.ShowDialog(this); }
(2)添加引用
DevExpress.BonusSkins
(3)DevExpress控件
拖一个DefaultLookAndFeel控件
(4)改变窗体继承
public partial class FrmSkin :DevExpress.XtraEditors.XtraForm
/// <summary> /// 把皮肤类型绑定到 LookUpEdit下拉框 /// </summary> private void DataSkin() { ArrayList list = new ArrayList(); //遍历皮肤,放到列表中 foreach (DevExpress.Skins.SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins) { list.Add(skin.SkinName); } //数据绑定 lookUpEdit1.Properties.DataSource = list; //是否显示列名 lookUpEdit1.Properties.ShowHeader = false; //是否显示底部 lookUpEdit1.Properties.ShowFooter = false; //显示第一项 lookUpEdit1.ItemIndex = 0; //最多显示10个下拉项 lookUpEdit1.Properties.DropDownRows = list.Count > 10 ? 10 : list.Count; }主题改变事件:
//皮肤 值改变事件 private void lookUpEdit1_TextChanged(object sender, EventArgs e) { if (lookUpEdit1.Text.Length > 0) { defaultLookAndFeel1.LookAndFeel.SetSkinStyle(lookUpEdit1.Text); } }
标签:winform 换肤 devexpress
原文地址:http://blog.csdn.net/u013816709/article/details/45310427