DevExpress换肤功能使用方法
1.在工程的引用中添对DevExpress.OfficeSkins的引用
2.在Program.cs中添以下两行代码:
DevExpress.UserSkins.OfficeSkins.Register();
DevExpress.Skins.SkinManager.EnableFormSkins();
3.在窗体上拖一个imageComboBoxEdit控件,控件name为imageComboBoxEdit1
4.在窗体的load事件中添加以下代码
// 给imageComboBoxEdit添加事伯
imageComboBoxEdit1.SelectedIndexChanged += new EventHandler(switchSkin);
// 取得所有可用皮肤名添加到combox
foreach (DevExpress.Skins.SkinContainer cnt in DevExpress.Skins.SkinManager.Default.Skins)
{
imageComboBoxEdit1.Properties.Items.Add(new ImageComboBoxItem(cnt.SkinName,cnt.SkinName));
//这一句是加在ribbon控件上的combox时用的
//repositoryItemImageComboBox2.Properties.Items.Add(new ImageComboBoxItem(cnt.SkinName, cnt.SkinName));
}
5.switchSkin方法如下:
public void switchSkin(object sender, EventArgs e)
{
ImageComboBoxEdit editor = sender as ImageComboBoxEdit;
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(editor.EditValue.ToString());
}
这样就可以使用imageComboBoxEdit来切换皮肤