Problem with DevExpress LookUpEdit

This should be a fairly simple task, however I'm a bit of a dead end, I have a LookUpEdit control, I bind it to the data source and set displaymember and ValueMenber correctly.

This control is now populated correctly.

My problem is that normally I would pull out some data and then β€œset” it to an identifier, for example:

LookUpEdit.EditValue = [Some identifiers from my database]

However, in this particular case, I do not have access to the ID, but I have access to the displymember value (from the database), so how do I set the LookUpEdit control to only take into account the displaymember value?

+3
source share
2 answers

Using:

lookUp.EditValue = lookUp.Properties.GetKeyValueByDisplayText(yourDisplayText);

This is the preferred method. Using the Text property is a little illogical, as you noted. It works now, but I won’t be surprised if it stops working in the future after updating the DevExpress assembly.

+7
source

I decided!

If you install it as follows:

LookUpEdit .Text = [String value from database]

IF this string value matches exactly, then editValue (i.e. the identifier) ​​is also set correctly for the item you pulled from the database.

This "Text" property seems somewhat illogical (in my opinion) (for example, they have GetDatasourceByName, etc., of course, it makes sense to have SetItemByName or something like that!), But it works anyway.

0

Source: https://habr.com/ru/post/1714313/


All Articles