How to: Customize ComboBox and Lookup Editors
- 2 minutes to read
The ComboBoxEdit and LookUpEdit controls derive from the LookUpEditBase class, and provide the same set of data editing capabilities. These include auto-complete, incremental filtering and edit value validation on text input. By default, however, the same capabilities are disabled for one data editor, while these are enabled for another editor. For instance, by default, the auto-complete feature is enabled for LookUpEdit and is disabled for ComboBoxEdit. This document describes the differences between ComboBoxEdit and LookUpEdit, and shows how to set-up this or that functionality.
The following table shows the default set-up of the ComboBox and Lookup data editors.
|Data Editor||Auto-Complete||Incremental Filtering||Input Validation|
Auto-Complete and Input Validation
If Automatic Completion is enabled, the text typed by an end-user within the edit box is automatically completed if it matches a value in the dropdown. Before the typed value is assigned to the editor's BaseEdit.EditValue property, it is validated. If an end-user has typed a new value that does not match any value displayed within the dropdown, the editor fires the LookUpEditBase.ProcessNewValue event allowing a new value to be added to an items source. If this event is not handled, a new value is automatically discarded.
The BaseEdit.ValidateOnTextInput option controls the times when data validation occurs. If it is enabled, the edit value is automatically validated while an end-user types within the edit box. Otherwise, the new value is validated before the editor loses focus. If the BaseEdit.ValidateOnEnterKeyPressed option is enabled, a new value is also validated after the ENTER key has been pressed.
Example: Enabling Data Editing in a ComboBoxEdit
<dxe:ComboBoxEdit Name="dxCombobox" DisplayMember="ProductName" ValueMember="ProductID" AutoComplete="True" ValidateOnTextInput="False" ProcessNewValue="dxCombobox_ProcessNewValue" />