Skip to main content
.NET 8.0+

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

SingleChoiceAction.ItemType Property

Specifies the type of a Single Choice Action’s items from the ChoiceActionBase.Items collection.

Namespace: DevExpress.ExpressApp.Actions

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

#Declaration

[DefaultValue(SingleChoiceActionItemType.ItemIsMode)]
public SingleChoiceActionItemType ItemType { get; set; }

#Property Value

Type Default Description
SingleChoiceActionItemType ItemIsMode

A SingleChoiceActionItemType enumeration value identifying a Single Choice Action’s items kind.

Available values:

Name Description
ItemIsMode

Items from a SingleChoiceAction‘s ChoiceActionBase.Items collection represent modes. The SingleChoiceAction’s control indicates the current selection.

ItemIsOperation

Items from a SingleChoiceAction‘s ChoiceActionBase.Items collection represent operations. The SingleChoiceAction’s control does not indicate the current selection.

#Remarks

Use this property to specify whether the Single Choice Action’s items represent a mode or an operation. Item type is considered when the Single Choice Action is displayed. When items represent modes, the Action’s control indicates the current selection. For items that represent operations, this functionality is not provided.

The example below demonstrates how to add a SingleChoiceAction and set it to perform operations.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;

// ...
public class SingleChoiceActionController : ObjectViewController<ListView, Person> {
    public SingleChoiceActionController() {
        SingleChoiceAction contactAction = new SingleChoiceAction(this, "ContactAction", PredefinedCategory.Edit);
        contactAction.ItemType = SingleChoiceActionItemType.ItemIsOperation;
        ChoiceActionItem openContact = new ChoiceActionItem("openContact", "Open Contact", null);
        ChoiceActionItem deleteContact = new ChoiceActionItem("deleteContact", "Delete Contact", null);
        contactAction.Items.Add(openContact);
        contactAction.Items.Add(deleteContact);
        contactAction.Execute += ContactAction_Execute;
    }
    private void ContactAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e) {
        if(View.CurrentObject != null) {
            if(e.SelectedChoiceActionItem.Id == "openContact") {
                IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Person));
                object currentObject = objectSpace.GetObject(View.CurrentObject);
                if(currentObject != null) {
                    e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, currentObject);
                }
                else {
                    objectSpace.Dispose();
                }
            }
            else if(e.SelectedChoiceActionItem.Id == "deleteContact") {
                View.ObjectSpace.Delete(View.CurrentObject);
                View.ObjectSpace.CommitChanges();
                View.Refresh(true);
            }
        }
    }
}

Items represent modes

SingleChoiceAction_ItemType_Mode

Items represent operations

SingleChoiceAction_ItemType_Operation

Note

The defined behavior is provided by built-in Action Containers. You can customize this by implementing a custom Action Container.

See Also