Skip to main content

How to: Enable Opening ComboBox's Dropdown Window Based on Custom Logic

The following code lists a PopupBaseEdit.QueryPopUp event handler which enables opening the dropdown window only if the user typed the text in the edit box which matches an item in the RepositoryItemComboBox.Items collection.

If the user typed a value which does not exist in the collection, the popup is not opened.

private void comboBoxEdit1_QueryPopUp(object sender, 
  System.ComponentModel.CancelEventArgs e) {
    ComboBoxEdit combo = sender as ComboBoxEdit;
    e.Cancel = combo.Properties.Items.IndexOf(combo.Text) == -1;
}