How to set the selected element of DevExpress LookupEdit by item? Ie, set the selection of LookupAdit based on the LookupAdit datasource given to an object.
You should set the property with the value from your data source according to the property < P> Here's a sample showing this approach:
var dataSource = new list & lt; Person & gt; {New person () {id = 0, name = "John", age = 27}, // ... new person () {id = 101, name = "mary", age = 23},}; LookupEdit1.Properties.DataSource = Data Source; LookupEdit1.Properties.DisplayMember = "name"; LookupEdit1.Properties.ValueMember = "ID"; LookupEdit1.EditValue = 101; // Select the person with ID == 101 // ... lookupEdit1.EditValue = lookupEdit1.Properties.GetDataSourceValue ("ID", 1); // Select the person from your ID from the second line
No comments:
Post a Comment