aby
aby

Reputation: 830

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

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

Upvotes: 1

Views: 8617

Answers (3)

DaveK
DaveK

Reputation: 4607

I ran into the same issue and resolved it by calling the 'ClosePopup()' method after manually setting the EditValue.

Upvotes: 0

Louwrens Potgieter
Louwrens Potgieter

Reputation: 117

If you only want one column in your LookupEdit control, do the following:

lkTest.Properties.DataSource=MyDataSource;
lkTest.Properties.ValueMember = "TypeID" ;
lkTest.Properties.DisplayMember = "pType";
lkTest.EditValue=1;  
LookUpColumnInfoCollection colType = lkTest.Columns;
if (colType.VisibleCount == 0)
   colType.Add(new LookUpColumnInfo("TypeID", "Type"));
lkTest.BestFitMode = BestFitMode.BestFitResizePopup;

Make sure your datasource MyDataSource has an TypeID equal to 1

Upvotes: 0

Niranjan Singh
Niranjan Singh

Reputation: 18290

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

Upvotes: 2

Related Questions