This example shows how to use LookupEdit and GridLookupEdit controls in combobox mode. In this mode, users can type in the text box and enter values that are not in the data source.
In this example, the LookupEdit is bound to an array of strings. The GridLookupEdit is bound to a list of business objects.
Do the following to enable the Combobox Mode:
-
Set the
Properties.TextEditStyleproperty toTextEditStyles.Standardto allow users to type in the text box. -
Set the
GridLookUpEditcontrol'sValueMemberandDisplayMemberproperties to the same data field (with string values). For theLookUpEdit, these proprties are not specified (set to an empty string).gridLookUpEdit1.Properties.ValueMember = "ProductName"; gridLookUpEdit1.Properties.DisplayMember = gridLookUpEdit1.Properties.ValueMember;
-
Enable the
AcceptEditorTextAsNewValueoptions property, which enables users to enter custom text in the edit box. -
Handle the
ProcessNewValueevent to parse entered values and add new records to the lookup’s data source.
Read the following help topic for more information: ComboBox Mode - Enter New Values.
(you will be redirected to DevExpress.com to submit your response)