Back to Devexpress

SingleChoiceAction.ItemType Property

expressappframework-devexpress-dot-expressapp-dot-actions-dot-singlechoiceaction-3588cb28.md

latest7.4 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
[DefaultValue(SingleChoiceActionItemType.ItemIsMode)]
public SingleChoiceActionItemType ItemType { get; set; }
vb
<DefaultValue(SingleChoiceActionItemType.ItemIsMode)>
Public Property ItemType As SingleChoiceActionItemType

Property Value

TypeDefaultDescription
SingleChoiceActionItemTypeItemIsMode

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

|

Available values:

NameDescription
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.

csharp
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

Items represent operations

Note

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the ItemType property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

xaf-how-to-import-data-in-xaf/CS/WinWebSolution.Module/ImportDataListViewController.cs#L38

csharp
importDataAction.PaintStyle = ActionItemPaintStyle.CaptionAndImage;
importDataAction.ItemType = SingleChoiceActionItemType.ItemIsOperation;
return importDataAction;

XAF-search-objects-using-complex-criterion/CS/Dennis.Search.Win/SearchObjectViewController.cs#L20

csharp
scaSearchObjectActionCore.ImageName = "Action_Search";
    scaSearchObjectActionCore.ItemType = SingleChoiceActionItemType.ItemIsOperation;
}

xaf-how-to-import-data-in-xaf/VB/WinWebSolution.Module/ImportDataListViewController.vb#L41

vb
importDataAction_Renamed.PaintStyle = ActionItemPaintStyle.CaptionAndImage
importDataAction_Renamed.ItemType = SingleChoiceActionItemType.ItemIsOperation
Return importDataAction_Renamed

XAF-search-objects-using-complex-criterion/VB/Dennis.Search.Win/SearchObjectViewController.vb#L26

vb
scaSearchObjectActionCore.ImageName = "Action_Search"
    scaSearchObjectActionCore.ItemType = SingleChoiceActionItemType.ItemIsOperation
End Sub

See Also

ItemTypeChanged

SingleChoiceAction Class

SingleChoiceAction Members

DevExpress.ExpressApp.Actions Namespace