Devexpress LookupEdit drops down the list rather than displaying a single element

aby picture aby · May 25, 2012 · Viewed 8k times · Source

To my surprise, the Devexpress LookupEdit keeps drop downing (displaying the list rather than only displaying the default Edit Value [one element]). What property is messing with me?

Here is how I set the properties:

lkTest.Properties.DataSource=MyDataSource;
        lkTest.Properties.ValueMember = "TypeID" ;
        lkTest.Properties.DisplayMember = "pType";
        lkTest.EditValue=1;

Thanks

Answer

Niranjan Singh picture Niranjan Singh · May 25, 2012

You not missing anything.

It is default behavior of the LookupEdit. If you just want to display the List of only Display member then you have to display that particular column in the lookupEdit.

To do this, create custom column in lookup Edit and then it will show only your created columns as like gridview.

First thing, When do you use LookupEdit???

When you want to display the detail of particular item then you can use it. If you just want to consume the combo box like behavior then use ComboBoxEdit control.

Check these code snippets, When i assign dataSource and EditValue, It does not show drop down by default to me.

When adding it to gridview.

lookupEdit = new RepositoryItemLookUpEdit();
lookupEdit.DataSource = dtResult;
lookupEdit.ValueMember = "Marks";
lookupEdit.DisplayMember = "Subject";        
gridView1.Columns[0].ColumnEdit = lookupEdit;

LookupEdit hosted on the Form:

lookUpEdit1.Properties.DataSource = dtResultType;
lookUpEdit1.Properties.ValueMember = "ID";
lookUpEdit1.Properties.DisplayMember = "ResultSubject";
lookUpEdit1.EditValue = 1;

Reference these links and Search result to get that what have you made wrong.
preferably i like you look at this - lookupedit editvalue after databinding

LookupEdit dropdown items shown when change position in datasource