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

ComboBoxEdit() Constructor

Creates and initializes a new instance of the ComboBoxEdit class.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v18.2.dll

Declaration

public ComboBoxEdit()

Remarks

Use the constructor to create combo box controls at runtime. After you create an editor, you can customize its appearance and behavior using the ComboBoxEdit.Properties property.

Example

The following code creates a combo box editor and adds three items to the item collection. Each item in the example is a PersonInfo class object, which stores a person’s first and last names.

The ComboBoxItemCollection.BeginUpdate and ComboBoxItemCollection.EndUpdate methods are called to prevent excessive updates when the item collection is changed (three items are added).

The BaseListBoxControl.SelectedIndex property is set to -1 for demonstration purposes (the property is set to -1 by default). This ensures that no item is currently selected in the combo box.

  ComboBoxEdit combo = new ComboBoxEdit();
  ComboBoxItemCollection coll = combo.Properties.Items;
  coll.BeginUpdate();
  try {
    coll.Add(new PersonInfo("Sven", "Petersen"));
    coll.Add(new PersonInfo("Cheryl", "Saylor"));
    coll.Add(new PersonInfo("Dirk", "Luchte"));
  }
  finally {
    coll.EndUpdate();
  }
  combo.SelectedIndex = -1;

  Controls.Add(combo);


//...

  public class PersonInfo {
    private string _firstName;
    private string _lastName;

    public PersonInfo(string firstName, string lastName) {
      _firstName = firstName;
      _lastName = lastName;
    }

    public override string ToString() {
      return _firstName + " " + _lastName;
    }
  }
See Also