lookupedit用法(combox功能)
绑定数据源:
RepositoryItemLookUpEdit lkt = new RepositoryItemLookUpEdit(); lkt.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ID", 20, "ID")); lkt.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("NAME", 30, "名称")); lkt.Properties.DataSource = dtTL_QXQ; lkt.Properties.DisplayMember = "NAME";//要显示的字段
lkt.Properties.ValueMember = "ID";//实际要用的字段
lkt.Properties.BestFit();
取值1:
private void lookUpEdit_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Escape)
{
(sender as LookUpEdit).EditValue = null;
}
}
取值2:
int roleID = lookUpEdit1.OldEditValue == null ? -1 : (Int32)lookUpEdit1.OldEditValue;
取值3:
判断是否选择下拉框:
if(this.lookUpEdit1.Editvalue==null)
{
//提示信息,说明未选择下拉框
}
清空nullText值:
lookUpEdit1.Properties.nulltext=null;
使用lookUpEdit1的值:
变量=this.lookUpEdit1.Editvalue.Tostring()//是ookUpEdit1.Properties.ValueMember的值
变量=this.lookUpEdit1.Text.Trim()//是ookUpEdit1.Properties.DisplayMember 的值
默认绑定:
1. lookUpEdit1.SelectionStart = 0;绑定第0个index
2. lookUpEdit1.EditValue = 1;//查找值等于1的index
3. lookupedit.itemindex=0; //选择第一项
4. lookupedit.itemindex=-1; //无选项,此时显示的是nulltext值 其实这个地方只要