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;
}