|
Author: Jenny Nguyen
|
|
DevExpress lookupedit works similar to the .NET combobox but when you want to set the desire item within the lookupedit it is a bit different to the combox. In this example you learn how to set the selected index for the lookupedit. Pay attention to the highlighted line. private void PopulatePlants() { DataTable dtPlants = new DataTable();
DbHelper db = new DbHelper(); db.StoredProcedure = "dbo.prPlantsSelect"; dtPlants = db.GetDataTable(); db.Close(); cbPlant.Properties.DisplayMember = "Description"; cbPlant.Properties.ValueMember = "ID"; cbPlant.Properties.DataSource = dtPlants;
//Set the desire index after the lookup has been populated. cbPlant.EditValue = cbPlant.Properties.GetKeyValueByDisplayText("TheSelectedIndexYouWant"); }
Comments (6)
"
|
personLookUpEdit.EditValue = personLookUpEdit.Properties.GetDataSourceRowByKeyValue(2);
-------------
private void PersonLookUpEditBoxBind()
{
try
{
BindingSource _BindingSource;
DataSet _DataSet = new DataSet();
DataTable _DataTable = new PersonBLL().SelectLookUpEdit();
_DataTable.TableName = "PERSON";
_DataSet.Tables.Add(_DataTable);
_BindingSource = new BindingSource(_DataSet, "PERSON");
personLookUpEdit.DataBindings.Add("EditValue", _BindingSource, "PERSONID");
personLookUpEdit.Properties.DataSource = _BindingSource;
personLookUpEdit.Properties.DisplayMember = "FULLNAME";
personLookUpEdit.Properties.ValueMember = "PERSONID";
LookUpColumnInfoCollection _LookUpColumnInfoCollection = personLookUpEdit.Pr...