网上搜索的 例子 加 自己的 一点点补充
lookupedit 设置选项值:
private void LookUpEditFormTest_Load(object sender, EventArgs e) { IListlist = HiscashsService.GetTableCovList(); this.comboBoxEdit1.Properties.DataSource = list; this.comboBoxEdit1.Properties.DisplayMember = "EN_CURRENT_BALANCE"; this.comboBoxEdit1.Properties.ValueMember = "I_ENTER_DATE"; comboBoxEdit1.Properties.Columns.Add(new LookUpColumnInfo("I_ENTER_DATE", "日期", 20)); comboBoxEdit1.Properties.Columns.Add(new LookUpColumnInfo("EN_CURRENT_BALANCE", "当前金额", 80)); //comboBoxEdit1.ItemIndex = 0;//选择第一项 comboBoxEdit1.ItemIndex = -1; //无选项,此时显示的是nulltext值 其实这个地方只要editvalue==null,lookupedit就显示nulltext } private void comboBoxEdit1_EditValueChanged(object sender, EventArgs e) { string name = this.comboBoxEdit1.SelectedText; string value = this.comboBoxEdit1.EditValue.ToString();//自动搜索datasouse,选择与之匹配的值,没有的情况下赋值null ,value的值必须与valuemember的数据类型一致。 MessageBox.Show(name+"==="+value); } /* 何问起 hovertree.com */
checkedComboBoxEdit 设置选项值:
public void TestFunc() { for (int i = 0; i < IniFunc().Count; i++) { if (IniFunc()[i].Isno == true) checkedComboBoxEdit1.Properties.Items.Add(i, IniFunc()[i].Name, CheckState.Checked, true); else checkedComboBoxEdit1.Properties.Items.Add(i, IniFunc()[i].Name, CheckState.Unchecked, true); } //取消第二列的选中状态 checkedComboBoxEdit1.Properties.Items[1].CheckState = CheckState.Unchecked; //checkedComboBoxEdit1 MessageBox.Show(this.checkedComboBoxEdit1.SelectedText + "===" + this.checkedComboBoxEdit1.EditValue.ToString()); } public BindingList IniFunc() { BindingList bindlist = new BindingList(); bindlist.Add(new Data { ID = 1, Name = "科比", Isno = true }); bindlist.Add(new Data { ID = 2, Name = "艾佛森", Isno = false }); bindlist.Add(new Data { ID = 3, Name = "姚明", Isno = false }); bindlist.Add(new Data { ID = 4, Name = "韦德", Isno = true }); bindlist.Add(new Data { ID = 5, Name = "詹姆斯", Isno = true }); return bindlist; } } public class Data { public int ID { get; set; } public string Name { get; set; } public bool Isno { get; set; } } /* 何问起 hovertree.com */
补充: checkedComboBoxEdit 多选设置
反绑定 重点:
DevExpress.XtraEditors.CheckedComboBoxEdit cmb_check_CKID = new DevExpress.XtraEditors.CheckedComboBoxEdit(); private void GetAllCK() { Listlist = (List )serviceLocator.GetService ().GetAllStore(StaticUser.ConmanyID);// LISt数据源 cmb_check_CKID.Properties.DataSource = list; cmb_check_CKID.Properties.DisplayMember = "STORENAME"; cmb_check_CKID.Properties.ValueMember = "ID"; cmb_check_CKID.Properties.SeparatorChar = ','; // 逗号 隔开 存储的 值是 编号(ID)如 2,3,4 } this.cmb_check_CKID.RefreshEditValue();//反绑定的 时候 这句很重要/* 何问起 hovertree.com */