- 3 minutes to read
A lookup editor is an editor with an embedded dropdown window, which displays lookup records (the records from which an end-user can select). When a lookup record is selected, the editor’s value (the EditValue bindable property) and display text are modified accordingly.
The first thing to do when setting up a lookup editor is assign a lookup data source (a set of lookup records displayed in the dropdown) to the editor. The lookup data source can be a DataTable, List, array of objects or simple data type values, etc. Lookup records must be unique values (in case the data source is an array of simple values) or contain a key field(s) that uniquely identifies each record. This ensures the proper functioning of the mechanism that matches the editor’s value with lookup records.
You then usually need to specify a key field that uniquely identifies lookup records (different properties are used in different binding modes) and a field that specifies values displayed in the edit box. You will find more information on setting up lookup editors in the topics that describe various binding modes (see below).
The DevExpress Windows Forms library offers several lookup editors that differ in the way they present the lookup records, and in the functionality they provide. For instance, the LookUpEdit control presents lookup records in a lightweight grid (tabular) format, while the GridLookUpEdit presents lookup records using an embedded feature-rich GridControl. See the following topic to learn more.
Typically, lookup editors are bound to values of simple data types (e.g., integer). However, they can also be bound to business objects. They also support an easy set up when the lookup data source is a Dictionary object. A special combobox mode is tailored to mimic the behavior of the standard ComboBox control, which allows for custom values to be entered. More information can be found in the topics below.
- Standard Binding (to Simple Data Types)
- Advanced Binding (to Business Objects)
- Using a Dictionary Lookup Data Source
- Combobox Mode - Allow Entering New Values
You may want to filter the popup data source of one (secondary) lookup editor based on the value of another (primary) lookup editor. This scenario is covered in the following topic.
Compared to the standard ComboBox control, lookup editors provide many additional features. Some of them are listed below.
- Presenting lookup records in various formats (when using different lookup editors).
- Multiple columns in the dropdown window (see the descriptions of the lookup editors).
- Enable or disable the text editing feature in the edit box (the RepositoryItemLookUpEditBase.TextEditStyle property).
- Adding custom values entered by an end-user to the lookup data source (LookUpEditBase.ProcessNewValue).
Creating unbound columns.