标签:
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