Skip to main content

CheckedComboBoxEdit.GetItemEnabled Event

Enables you to disable specific items.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Events")]
public event GetCheckedComboBoxItemEnabledEventHandler GetItemEnabled

Event Data

The GetItemEnabled event's data class is DevExpress.XtraEditors.Controls.GetCheckedComboBoxItemEnabledEventArgs.

Remarks

This event fires for each item when a popup window is opened. It allows you to disable specific items according to your requirements. To disable items, set the event’s Enabled parameter to false.

The event’s Index and ListSourceRowIndex parameters identify the currently processed item.

The ListSourceRowIndex parameter identifies an item’s index in the RepositoryItemCheckedComboBoxEdit.Items collection. If a CheckedComboBoxEdit control is bound to a data source (RepositoryItemCheckedComboBoxEdit.DataSource), the ListSourceRowIndex parameter also addresses a corresponding row in this data source.

A CheckedComboBoxEdit control contains a “Select All” item, provided that the RepositoryItemCheckedComboBoxEdit.SelectAllItemVisible property is set to true. The GetItemEnabled event also fires for the “Select All” item. In this instance, the ListSourceRowIndex parameter is set to -1.

The Index parameter specifies the visual position of the currently processed item among displayed check items (including the “Select All” item, if it’s visible). If the “Select All” item is visible, the Index parameter is set to 0 for this item. Subsequent indexes correspond to items in the RepositoryItemCheckedComboBoxEdit.Items collection.

If the “Select All” item is not visible, the Index of 0 corresponds to the first item in the RepositoryItemCheckedComboBoxEdit.Items collection, the Index of 1 corresponds to the second item in the RepositoryItemCheckedComboBoxEdit.Items collection and so on.

The event’s ListBox parameter allows you to access a CheckedListBoxControl control. This control displays check items in the CheckedComboBoxEdit‘s popup window.

Example

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