windowsforms-116019-controls-and-libraries-editors-and-simple-controls-lookup-editors-combobox-mode-allow-entering-new-values.md
The LookUpEdit and GridLookUpEdit controls allow users to type in the text box and enter values that are not in the data source (ComboBox mode). The SearchLookUpEdit and TreeListLookUpEdit controls do not allow users to add new values.
Do the following to enable users to enter new values:
Standard to allow users to type in the text box.Note
Do not specify the ValueMember and DisplayMember properties (set them to an empty string instead) if a lookup is bound to an array of strings.
EditValue property.Note
Handle the ProcessNewValue event to parse entered values and add new records to the lookup’s data source. In inplace mode, you should always add new values to the lookup’s data source.
Read the following topic for detailed information on how to add new values to the lookup’s data source: Lookups - How to Enter New Values and Post Them to Data Source.
This example shows how to switch the LookUpEdit control that displays an array of strings to ComboBox mode.
using DevExpress.Utils;
using DevExpress.XtraEditors.Controls;
// Binds the lookup to an array of strings.
lookUpEdit1.Properties.DataSource = new List<string>() {
"London", "New York", "Tokyo", "Berlin" };
// Enables adding new values.
lookUpEdit1.Properties.TextEditStyle = TextEditStyles.Standard;
lookUpEdit1.Properties.AcceptEditorTextAsNewValue = DefaultBoolean.True;
Imports DevExpress.Utils
Imports DevExpress.XtraEditors.Controls
' Binds the lookup to an array of strings.
lookUpEdit1.Properties.DataSource = New List(Of String)() From {"London", "New York", "Tokyo", "Berlin"}
' Enables adding new values.
lookUpEdit1.Properties.TextEditStyle = TextEditStyles.Standard
lookUpEdit1.Properties.AcceptEditorTextAsNewValue = DefaultBoolean.True
This example shows how to switch the GridLookUpEdit control to ComboBox mode.
using DevExpress.Utils;
using DevExpress.XtraEditors.Controls;
using System.ComponentModel.DataAnnotations;
// Binds the grid lookup to a list of data objects.
gridLookUpEdit1.Properties.DataSource = Department.Init();
gridLookUpEdit1.Properties.DisplayMember = "Name";
gridLookUpEdit1.Properties.ValueMember = "Name";
// Enables adding new values.
gridLookUpEdit1.Properties.TextEditStyle = TextEditStyles.Standard;
gridLookUpEdit1.Properties.AcceptEditorTextAsNewValue = DefaultBoolean.True;
Imports DevExpress.Utils
Imports DevExpress.XtraEditors.Controls
Imports System.ComponentModel.DataAnnotations
' Binds the grid lookup to a list of data objects.
gridLookUpEdit1.Properties.DataSource = Department.Init()
gridLookUpEdit1.Properties.DisplayMember = "Name"
gridLookUpEdit1.Properties.ValueMember = "Name"
' Enables adding new values.
gridLookUpEdit1.Properties.TextEditStyle = TextEditStyles.Standard
gridLookUpEdit1.Properties.AcceptEditorTextAsNewValue = DefaultBoolean.True
See Also