首页 > 代码库 > 步入DevExpress的使用(VS)

步入DevExpress的使用(VS)

1、下载安装DevExpress控件(如DXperienceUniversal-11.1.12.exe),安装后路径:“C:\Program Files (x86)\DevExpress 2011.1”。

2、找到安装后DevExpress控件的DLL(要使用的DLL),路径是“C:\Program Files (x86)\DevExpress 2011.1\Components\Sources\DevExpress.DLL”,拷贝到自己需要的地方,以方便项目添加引用时通过“浏览”找到;不拷贝也可以,项目引用时选择“项目集”>>“扩展”下找到。

3、在界面的“工具箱”中,添加一选项卡,命名如:“DevExpress”,并右击“选择项”,在.Net Framework组件中找到需要的控件名(可按控件的首字符查找),如:“DefaultLookAndFeel”,然后添加对应的DLL,如“DevExpress.Utils.v11.1.dll”(若自动添加也可以不添加)。

4、向对话框中添加:DefaultLookAndFeel、ComboBoxEdit控件等

5、实现的具体代码如下:

(1)Program.cs

using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;namespace TestExpressSkins{    static class Program    {        /// <summary>        /// 应用程序的主入口点。        /// </summary>        [STAThread]        static void Main()        {            DevExpress.UserSkins.BonusSkins.Register();            DevExpress.UserSkins.OfficeSkins.Register();            DevExpress.Skins.SkinManager.EnableFormSkins();                        Application.EnableVisualStyles();            Application.SetCompatibleTextRenderingDefault(false);            Application.Run(new Form1());        }    }}

 

(2)Form1.cs

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace TestExpressSkins{    public partial class Form1 : DevExpress.XtraEditors.XtraForm            //Form    {        private CommonFunctions commFunc = null;        public Form1()        {            InitializeComponent();            commFunc = CommonFunctions.Singlon();        }        private void Form1_Load(object sender, EventArgs e)        {            commFunc.AddAppStyles2ComboBoxEdit(cmbAppStyle);        }        private void cmbAppStyle_SelectedIndexChanged(object sender, EventArgs e)        {            this.defaultLookAndFeel1.LookAndFeel.SkinName = cmbAppStyle.EditValue.ToString();        }    }}

 

(3)CommonFunctions.cs

using DevExpress.XtraEditors;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace TestExpressSkins{    class CommonFunctions    {        #region 单例        private static CommonFunctions commFuncInstance = null;        private CommonFunctions()        {        }        public static CommonFunctions Singlon()        {            if (null == commFuncInstance)            {                commFuncInstance = new CommonFunctions();            }            return commFuncInstance;        }        #endregion        /// <summary>        /// 皮肤全部枚举出来放到一个ComboBoxEdit中        /// </summary>        /// <param name="comboBoxEdit"></param>        public void AddAppStyles2ComboBoxEdit(ComboBoxEdit comboBoxEdit)        {            foreach (DevExpress.Skins.SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins)            {                comboBoxEdit.Properties.Items.Add(skin.SkinName);            }        }        public bool tmpFunc()        {            bool bFlag = true;                       return bFlag;        }    }}

 

步入DevExpress的使用(VS)