Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Disable CheckedComboBoxEdit's Items via Event

In the following example, it’s assumed that a CheckedComboBoxEdit control is bound to a data source containing a “Discontinued” field. The following code shows how to disable a CheckedComboBoxEdit control’s items, whose Discontinued fields are set to false. This is accomplished by handling the CheckedComboBoxEdit.GetItemEnabled event.

using DevExpress.XtraEditors;

private void checkedComboBoxEdit1_GetItemEnabled(object sender, 
    DevExpress.XtraEditors.Controls.GetCheckedComboBoxItemEnabledEventArgs e) {
    if (e.ListSourceRowIndex == -1) return;
    CheckedComboBoxEdit control = sender as CheckedComboBoxEdit;
    bool isDiscontinued = (bool)((control.Properties.DataSource as BindingSource)[e.ListSourceRowIndex] as DataRowView)["Discontinued"];
    e.Enabled = !isDiscontinued;
}