ActionBase.CustomizeControl Event
Occurs after the control is initialized. Allows customizing the default control settings.
Namespace: DevExpress.ExpressApp.Actions
Assembly: DevExpress.ExpressApp.v21.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
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.v21.2.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 21.2\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 Web Forms Specific Scenarios
-
The returned value type:
- SimpleActionMenuActionItem - for menu Actions;
- ASPxGridViewCustomButtonInitializer - for Inline Grid Actions.
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.
The returned value type:
- ASPxNavBar - if the IModelRootNavigationItems.NavigationStyle property is set to NavigationStyle.NavBar;
- ASPxTreeView - if the IModelRootNavigationItems.NavigationStyle property is set to NavigationStyle.TreeList.
-
The returned value type is ParametrizedActionMenuActionItem.
-
The returned value type:
- PopupWindowActionMenuActionItem - for menu Actions;
- ASPxGridViewCustomButtonInitializer - for Inline Grid Actions.
WinForms Specific Scenarios
-
The returned value type:
- SimpleButton - for Layout Actions;
- BarButtonItem - for BarManager Actions.
-
The returned value type:
- ImageComboBoxEdit - for Layout Actions;
- BarEditItem, BarButtonItem, RibbonGalleryBarItem - for BarManager Actions.
ShowNavigationItem Action returned by the ShowNavigationItemController.ShowNavigationItemAction property.
The returned value type:
- NavBarControl - if the IModelRootNavigationItems.NavigationStyle property is set to NavigationStyle.NavBar;
- TreeList - if the IModelRootNavigationItems.NavigationStyle property is set to NavigationStyle.TreeList.
-
The returned value type:
- Descendants of ButtonEdit (SpinEdit, ButtonEditWithClearButton, DateEdit) - for Layout Actions;
- BarEditItem - for BarManager Actions.
-
The returned value type:
- SimpleButton - for Layout Actions;
- BarButtonItem - for BarManager Actions.
ASP.NET Core Blazor Specific Scenarios
-
The returned value type is DxToolbarItemSimpleActionControl.
myAction.CustomizeControl += (s, e) => { DxToolbarItemSimpleActionControl actionControl = e.Control as DxToolbarItemSimpleActionControl; //... }
-
The returned value type depends on the SingleChoiceAction.ItemType property value and ChoiceActionItems sub items:
- DxToolbarComboBoxItemSingleChoiceActionControl;
- DxToolbarItemSingleChoiceActionControl.
myAction.CustomizeControl += (s, e) => { DxToolbarComboBoxItemSingleChoiceActionControl actionControl = e.Control as DxToolbarComboBoxItemSingleChoiceActionControl; // or DxToolbarItemSingleChoiceActionControl actionControl = e.Control as DxToolbarItemSingleChoiceActionControl; //... }
-
The returned value type is DxToolbarItemParametrizedActionControl.
myAction.CustomizeControl += (s, e) => { DxToolbarItemParametrizedActionControl actionControl = e.Control as DxToolbarItemParametrizedActionControl; //... }
-
The returned value type is DxToolbarItemSimpleActionControl.
myAction.CustomizeControl += (s, e) => { DxToolbarItemSimpleActionControl actionControl = e.Control as DxToolbarItemSimpleActionControl; //... }