Program.cs代码如下:

 

[c-sharp] view plaincopy
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Windows.Forms;  
  4.   
  5. namespace testDevExpress  
  6. {  
  7.     static class Program  
  8.     {  
  9.         /// <summary>  
  10.         /// 应用程序的主入口点。  
  11.         /// </summary>  
  12.         [STAThread]  
  13.         static void Main()  
  14.         {  
  15.             DevExpress.UserSkins.OfficeSkins.Register();  
  16.             DevExpress.UserSkins.BonusSkins.Register();  
  17.   
  18.             Application.EnableVisualStyles();  
  19.               
  20.             Application.SetCompatibleTextRenderingDefault(false);  
  21.             if (!DevExpress.Skins.SkinManager.AllowFormSkins)  
  22.             {  
  23.                 DevExpress.Skins.SkinManager.EnableFormSkins();  
  24.             }  
  25.             DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Black";  
  26.   
  27.             Application.Run(new XtraForm1());  
  28.         }  
  29.     }  
  30. }  

建立一个XtraForm 。

添加 一个 comboBoxEX ,代码初始化:

string[] arr ={ "Black", "Blue", "Red" };
            comboBoxEx1.DataSource = arr;

 

然后 响应comboBoxEx1_SelectedIndexChanged代码如下:

[c-sharp] view plaincopy
  1. private void comboBoxEx1_SelectedIndexChanged(object sender, EventArgs e)  
  2.         {  
  3.             //MessageBox.Show("here");  
  4.             string cc = comboBoxEx1.SelectedText.ToString();  
  5.             label1.Text= comboBoxEx1.SelectedItem.ToString();  
  6.             DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = comboBoxEx1.SelectedItem.ToString();  
  7.         }  

 

可以在下拉菜单中选择颜色,住窗体变化主题颜色。


本文转载:CSDN博客