Program.cs代码如下:
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- namespace testDevExpress
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- DevExpress.UserSkins.OfficeSkins.Register();
- DevExpress.UserSkins.BonusSkins.Register();
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- if (!DevExpress.Skins.SkinManager.AllowFormSkins)
- {
- DevExpress.Skins.SkinManager.EnableFormSkins();
- }
- DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Black";
- Application.Run(new XtraForm1());
- }
- }
- }
建立一个XtraForm 。
添加 一个 comboBoxEX ,代码初始化:
string[] arr ={ "Black", "Blue", "Red" };
comboBoxEx1.DataSource = arr;
然后 响应comboBoxEx1_SelectedIndexChanged代码如下:
- private void comboBoxEx1_SelectedIndexChanged(object sender, EventArgs e)
- {
- //MessageBox.Show("here");
- string cc = comboBoxEx1.SelectedText.ToString();
- label1.Text= comboBoxEx1.SelectedItem.ToString();
- DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = comboBoxEx1.SelectedItem.ToString();
- }
可以在下拉菜单中选择颜色,住窗体变化主题颜色。