Hai all,我在C#.NET项目中使用DevExpress LookupEdit,同时设置了LookupEdit的Display Member和Value成员属性,并且项目没有在LookupEdit列表页面上显示,但我可以选择项目。选择一个项目后,所选项目在LookupEdit文本上显示。请帮忙
lkpReference.Properties.DataSource = _lab.selectLabReference() ;
lkpReference.Properties.DisplayMember = "refernce_name";
lkpReference.Properties.ValueMember = "lab_ref_id";
lkpReference.Properties.BestFitMode = BestFitMode.BestFit;
lkpReference.Properties.SearchMode = SearchMode.AutoComplete;
LookUpColumnInfoCollection collns = lkpReference.Properties.Columns;
collns.Add(new LookUpColumnInfo("Lab Reference", 0));
lkpReference.Properties.AutoSearchColumnIndex = 1;
答案 0 :(得分:1)
lkpReference.Properties.DataSource = _lab.selectLabReference() ;
lkpReference.Properties.DisplayMember = "refernce_name";
lkpReference.Properties.ValueMember = "lab_ref_id";
lkpReference.Properties.BestFitMode = BestFitMode.BestFit;
lkpReference.Properties.SearchMode = SearchMode.AutoComplete;
// the constructor you are using accepts 2 parameters: FieldName (which is the name
// of the field from the DataTable) and Width (which is the width of the column
// displayed in the dropdown). You have set both parameters wrong.
//LookUpColumnInfoCollection collns = lkpReference.Properties.Columns;
//collns.Add(new LookUpColumnInfo("Lab Reference", 0));
// what you intended to do is this
lkpReference.Properties.Columns.Add(new LookUpColumnInfo("refernce_name", 100, "Lab Reference"));
lkpReference.Properties.AutoSearchColumnIndex = 1;