Skip to main content
A newer version of this page is available. .

Combobox Mode - Allow Entering New Values

  • 7 minutes to read

In Combobox Mode, a LookUpEdit and GridLookUpEdit controls can act as a standard Windows Forms ComboBox control.

  • The editor’s dropdown displays records from a lookup data source.
  • An end-user can enter any value in the edit box, including values that do not exist in the lookup data source.

lookup-comboboxmode-example-result.gif

To enable combobox mode, use the following properties.

Note

The SearchLookUpEdit and TreeListLookUpEdit controls do not support combobox mode.

Example

This example shows the use of LookupEdit and GridLookupEdit controls in combobox mode, in which the editors accept any text in the edit box. An end-user can select an existing value from a lookup data source or type any string. The text entered is saved in the editor’s edit value when the editor loses focus.

Lookup data sources for the LookupEdit and GridLookupEdit controls are an array of strings and a list of business objects, respectively.

Combobox mode is enabled when the following conditions are met:

  • the AcceptEditorTextAsNewValue property enables entering custom text in the edit box.

  • the ValueMember and DisplayMember properties are set to an empty string (see the LookupEdit control initialization), or to the same field in the lookup data source (see the GridLookupEdit control initialization).

  • the TextEditStyle property is set to Standard to enable text editing.

lookup-comboboxmode-example-form.png

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lookup_ComboboxMode {
    static class Program {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}