ChoiceActionItem.Enabled Property
Provides access to a collection of reason/value pairs used to make a ChoiceActionItem enabled\disabled or to determine its enabled state.
Namespace: DevExpress.ExpressApp.Actions
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
#Declaration
#Property Value
Type | Description |
---|---|
Bool |
A Bool |
#Remarks
The decision to enable or disable a Choice Action Item is made based on all the requests collected at the current moment. For instance, the system allows enabling because the object with which the Choice Action Item is associated is available, but the Security System can make it disabled because it is not intended for the current user. So, a Choice Action Item has the Enabled collection, whose elements represent a pair of string and Boolean values. The string value specifies a reason and the Boolean value specifies whether to make disabled the Choice Action Item for this reason. A Choice Action Item is considered enabled if none of the Enabled collection elements contain a false value.
To determine whether a Choice Action Item is currently enabled, use the Enabled property in a conditional expression. Alternatively, use the BoolList.ResultValue property of the object returned by Enabled.
ChoiceActionItem myItem;
//...
BoolList enabledList = myItem.Enabled;
if (enabledList) {
//...
}
To disable an enabled Choice Action Item, use the BoolList.SetItemValue method of the BoolList object returned by this property. Pass the disabling reason as the first parameter, and false, or a Boolean expression, as the second parameter. Alternatively, you can use the [key] operator of the BoolList object returned by the Enabled property, to get or set the specified key’s value.
ChoiceActionItem myItem;
//...
BoolList enabledList = myItem.Enabled;
enabledList["myKey"] = false;
To enable a disabled Choice Action Item, use the BoolList.RemoveItem method of the BoolList object, returned by this property. Pass the key (reason) of the item with the false value. If this is a single item that has the false value, the Choice Action Item will be enabled. Alternatively, you can use the BoolList.SetItemValue method by passing the key, which has false as a value, and true as a new value for it.
ChoiceActionItem myItem;
//...
BoolList enabledList = myItem.Enabled;
enabledList["disablingKey"] = true;
When a Choice Action Item’s enabled state is changed, the ChoiceActionBase.ItemsChanged event is raised.