lookUpEdit 绑定数据
//绑定lookUpEdit
private void BoundData()
{
string sql = "select daID,xm,sfzh from baseinfo";
DataSet ds = bga.getTable(sql);
if (ds != null)
{
int rows = ds.Tables[0].Rows.Count;
lookUpEdit1.EditValue = "daID";
lookUpEdit1.Properties.ValueMember = "daID";
lookUpEdit1.Properties.DisplayMember = "xm";
lookUpEdit1.Properties.DataSource = ds.Tables[0];
//自适应宽度
//lookUpEdit1.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
//填充列
lookUpEdit1.Properties.PopulateColumns();
//设置列属性
//lookUpEdit1.Properties.Columns[0].Visible = false;
lookUpEdit1.Properties.Columns[1].Caption = "姓名";
lookUpEdit1.Properties.Columns[2].Caption = "身份证号";
lookUpEdit1.Properties.Columns[1].Width = 120;
lookUpEdit1.Properties.Columns[2].Width = 300;
//控制选择项的总宽度
lookUpEdit1.Properties.PopupWidth = 500;
//列格式设置
lookUpEdit1.Properties.Columns[0].FormatString = "000000";
//选择第一项
lookUpEdit1.ItemIndex = 0;
}
}
//值改变事件
private void lookUpEdit1_EditValueChanged(object sender, EventArgs e)
{
string daID = this.lookUpEdit1.EditValue.ToString();
//是ookUpEdit.Properties.ValueMember的值
string xm = this.lookUpEdit1.Text.Trim();
}