How to get the devexpress lookupedit display text from the corresponding edit value

Vyasdev Meledath picture Vyasdev Meledath · Sep 18, 2010 · Viewed 35.1k times · Source

Hai all,

I want to get lookupedit display text when am giving correspond edit value.

example: if am giving

LookupEdit1.Editvalue="3";

then it should show display text of Editvalue="3"

please help

//code

 cmbChemical.Properties.DataSource = _lab.selectChemicals();
        cmbChemical.Properties.DisplayMember = "labitem_Name";
        cmbChemical.Properties.ValueMember = "labItem_ID";
        cmbChemical.Properties.BestFitMode = BestFitMode.BestFit;
        cmbChemical.Properties.SearchMode = SearchMode.AutoComplete;

        cmbChemical.Properties.Columns.Add(new LookUpColumnInfo("labitem_Name", 100,  "Chemicals"));
    cmbChemical.Properties.AutoSearchColumnIndex = 1;

Answer

devnull picture devnull · Sep 18, 2010

You can't, at least not in the way you're trying. The LookUpEdit, as the name implies, looks up its values in a DataSource, eg. a collection of objects. Therefore, to display the value 3 you need to have a list of objects that contains this value and set it as a DataSource for the control.

List<string> values = new List<string>();
values.Add("3");
lookUpEdit.Properties.DataSource = values;
lookUpEdit.EditValue = "3";

Maybe if you specify what are you trying to do, we can help you achieve that.