Skip to main content
A newer version of this page is available. .

ActionBase.CustomizeControl Event

Occurs after the control is initialized. Allows customizing the default control settings.

Namespace: DevExpress.ExpressApp.Actions

Assembly: DevExpress.ExpressApp.v19.1.dll

Declaration

public event EventHandler<CustomizeControlEventArgs> CustomizeControl

Event Data

The CustomizeControl event's data class is CustomizeControlEventArgs. The following properties provide information specific to this event:

Property Description
Control Gets an object that allows you to access the control which is used to display an Action.

Remarks

The example below demonstrates how to change a SimpleAction color in WinForms applications.

using System.Drawing;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.XtraBars;
// ...
public class ChangeActionColorController : WindowController {
    public ChangeActionColorController() {
        SimpleAction simpleAction = new SimpleAction(this, "Action", PredefinedCategory.Edit);
        simpleAction.CustomizeControl += SimpleAction_CustomizeControl;
    }
    private void SimpleAction_CustomizeControl(object sender, CustomizeControlEventArgs e) {
        BarButtonItem button = e.Control as BarButtonItem;
        if(button != null) {
            button.ItemAppearance.Normal.BackColor = Color.LightBlue;
        }
    }
}

Note

To run this code, add the DevExpress.ExpressApp.XtraBars.v19.1.dll assembly to References.

Do not handle this event for a built-in Action in a View or Window Controller‘s OnActivated method because this method is called after the Action controls creation. Use the OnFrameAssigned method instead.

The CustomizeControlEventArgs.Control event parameter returns the Action Item object which provides access to the control settings. See all of the possible scenarios in the Action section of the Feature Center demo that is installed in the %PUBLIC%\Documents\DevExpress Demos 19.1\Components\eXpressApp Framework\FeatureCenter folder by default, or refer to the Feature Center demo online. The lists below show which type of Action Item is returned for different Action types.

ASP.NET Specific Scenarios

  • SimpleAction

    Returned value type:

    myAction.CustomizeControl += (s, e) => {
        SimpleActionMenuActionItem actionItem = e.Control as SimpleActionMenuActionItem;
        // or 
        ASPxGridViewCustomButtonInitializer initializer = e.Control as ASPxGridViewCustomButtonInitializer;
        //...
    }
    
  • SingleChoiceAction menu Actions.

    The returned value type depends on the SingleChoiceAction.ItemType property value and ChoiceActionItems sub items:

    • SingleChoiceActionAsModeMenuActionItem;
    • SingleChoiceActionItemAsHierarchicalModeActionMenuItem;
    • SingleChoiceActionItemAsOperationActionMenuItem.
    myAction.CustomizeControl += (s, e) => {
        SingleChoiceActionAsModeMenuActionItem actionItem = e.Control as SingleChoiceActionAsModeMenuActionItem;
        // or
        SingleChoiceActionItemAsHierarchicalModeActionMenuItem actionItem = e.Control as SingleChoiceActionItemAsHierarchicalModeActionMenuItem;
        // or
        SingleChoiceActionItemAsOperationActionMenuItem actionItem = e.Control as SingleChoiceActionItemAsOperationActionMenuItem;
        //...
    }
    
  • ShowNavigationItem Action returned by the ShowNavigationItemController.ShowNavigationItemAction property.

    Returned value type:

    Frame.GetController<ShowNavigationItemController>().ShowNavigationItemAction.CustomizeControl += (s, e) => {
        ASPxNavBar navBar = e.Control as ASPxNavBar;
        // or
        ASPxTreeView treeView = e.Control as ASPxTreeView;
        //...
    }
    
  • ParametrizedAction.

    Returned value type is ParametrizedActionMenuActionItem.

    myAction.CustomizeControl += (s, e) => {
        ParametrizedActionMenuActionItem actionItem = e.Control as ParametrizedActionMenuActionItem;
        //...
    }
    
  • PopupWindowShowAction.

    Returned value type:

    myAction.CustomizeControl += (s, e) => {
        PopupWindowActionMenuActionItem actionItem = e.Control as PopupWindowActionMenuActionItem;
        // or
        ASPxGridViewCustomButtonInitializer actionItem = e.Control as ASPxGridViewCustomButtonInitializer;
        //...
    }
    

WinForms Specific Scenarios

  • SimpleAction.

    Returned value type:

    myAction.CustomizeControl += (s, e) => {
        SimpleButton control = e.Control as SimpleButton;
        // or
        BarButtonItem control = e.Control as BarButtonItem;
        //...
    }
    
  • SingleChoiceAction.

    Returned value type:

    myAction.CustomizeControl += (s, e) => {
        ImageComboBoxEdit control = e.Control as ImageComboBoxEdit;
        // or
        BarEditItem control = e.Control as BarEditItem;
        //...
    }
    
  • ShowNavigationItem Action returned by the ShowNavigationItemController.ShowNavigationItemAction property.

    Returned value type:

    Frame.GetController<ShowNavigationItemController>().ShowNavigationItemAction.CustomizeControl += (s, e) => {
        NavBarControl navBar = e.Control as NavBarControl;
        // or
        TreeList treeList = e.Control as TreeList;
        //...
    }
    
  • ParametrizedAction.

    Returned value type:

    myAction.CustomizeControl += (s, e) => {
        DateEdit control = e.Control as DateEdit;
        // or
        BarEditItem control = e.Control as BarEditItem;
        //...
    }
    
  • PopupWindowShowAction.

    Returned value type:

    myAction.CustomizeControl += (s, e) => {
        SimpleButton control = e.Control as SimpleButton;
        // or
        BarButtonItem control = e.Control as BarButtonItem;
        //...
    }
    

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomizeControl event.

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.

See Also