1

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

Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75
aby
  • 810
  • 6
  • 21
  • 36

3 Answers3

2

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

Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75
  • Sorry, I think i didn't make my problem clear. I know how the LookupEdit works and when to use it. The problem is when I set the EditValue it pops up and shows the whole list. I want it to be collapsed when it is displayed. Thanks – aby May 25 '12 at 13:40
  • ok.. can you explain the situation, how are you using it .. it is working fine for me.. not showing any popup when i assign `dataSource` to it and then set the `EditValue` to it. – Niranjan Singh May 25 '12 at 14:08
  • The thing is, elements of the LookupEdit are supposed to be displayed/listed when the drop down button is clicked. But now, it's showing them with the LookupEdit control expanded/in a dropped down mode. The control should be in a collapsed mode. – aby May 26 '12 at 05:49
  • i think your binding is not correct.. check updated links in the answer.. may be they will help you get that what is going wrong.. – Niranjan Singh May 26 '12 at 11:19
  • create a sample project, attach it to devexpress fourm and then put the link of your thread. may be after that possible get the issue with your code.. – Niranjan Singh May 28 '12 at 13:46
0

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

0

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

DaveK
  • 4,509
  • 3
  • 33
  • 33