码迷,mamicode.com
首页 > 其他好文 > 详细

Dev Express之ImageComboBoxEdit,RepositoryItemImageComboBox使用方式

时间:2016-05-11 13:24:37      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

 Dev Express之ImageComboBoxEdit,RepositoryItemImageComboBox使用方式

1.使用ImageComboBoxEdit实现下拉框键值数据函数

        public static void InitCmb(ImageComboBoxEdit cmb, DataTable source, string value, string text, bool isDefaultNull)
        {
            ImageComboBoxItem[] items = new ImageComboBoxItem[source.Rows.Count +1];
            int i = 0;
            if (isDefaultNull)
            {
                items[i] = new ImageComboBoxItem();
                items[i].Description = "";
                items[i].Value = "";
                items[i].ImageIndex = -1;
                i++;
            }

            foreach (DataRow dr in source.Rows)
            {
                items[i] = new ImageComboBoxItem();
                items[i].Description = dr[text].ToString();
                items[i].Value = dr[value]; 
                items[i].ImageIndex = -1;
                i++;
            }
            cmb.Properties.Items.Clear();
            cmb.Properties.Items.AddRange(items);            
            cmb.EditValue = items[0].Value;
        }

2.使用RepositoryItemImageComboBox实现GridControl内容Cell内下拉键值数据函数

        public static void InitCmb(RepositoryItemImageComboBox repImageComboBox, DataTable source,string value,string text,bool isDefaultNull)
        {
            ImageComboBoxItem[] items = new ImageComboBoxItem[source.Rows.Count+1];
            int i=0;
            if (isDefaultNull)
            {
                items[i] = new ImageComboBoxItem();
                items[i].Description = "";
                items[i].Value = "";
                items[i].ImageIndex = -1;
                i++;
            }
            foreach (DataRow dr in source.Rows)
            {
                items[i] = new ImageComboBoxItem();
                items[i].Description = dr[text].ToString();
                items[i].Value = dr[value];
                items[i].ImageIndex = -1;
                i++;
            }
            repImageComboBox.Items.AddRange(items);
        }

3.使用RepositoryItemImageComboBox/ImageComboBox与ImageCollection结合实现GridControl内容Cell内下拉图片数据函数

        public static void InitImgCmb(RepositoryItemImageComboBox repImageComboBox, DataTable source, string value, bool isDefaultNull)
        {
            ImageComboBoxItem[] items = new ImageComboBoxItem[source.Rows.Count + 1];
            int i = 0;
            if (isDefaultNull)
            {
                items[i] = new ImageComboBoxItem();
                items[i].Description = "";
                items[i].Value = "";
                items[i].ImageIndex = -1;
                i++;
            }
            foreach (DataRow dr in source.Rows)
            {
                items[i] = new ImageComboBoxItem();
                items[i].Description = "";
                items[i].Value = dr[value];
                if(Int32.Parse(items[i].Value.ToString()) == 0){
                    items[i].ImageIndex = 0;
                }else if(Int32.Parse(items[i].Value.ToString()) == 1){
                    items[i].ImageIndex = 1;
                }else if(Int32.Parse(items[i].Value.ToString()) == 2){
                    items[i].ImageIndex = 2;
                }else if(Int32.Parse(items[i].Value.ToString()) == 3){
                    items[i].ImageIndex = 3;
                }else if(Int32.Parse(items[i].Value.ToString()) == 4){
                    items[i].ImageIndex = 4;
                }
                i++;
            }
            repImageComboBox.Items.AddRange(items);
        }

 

Dev Express之ImageComboBoxEdit,RepositoryItemImageComboBox使用方式

标签:

原文地址:http://www.cnblogs.com/ultimateWorld/p/5481394.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!