expressappframework-devexpress-dot-expressapp-dot-actions-dot-actionbase-255d5030.md
Fires after the control is initialized. Allows you to customize the control.
Namespace : DevExpress.ExpressApp.Actions
Assembly : DevExpress.ExpressApp.v25.2.dll
NuGet Package : DevExpress.ExpressApp
public event EventHandler<CustomizeControlEventArgs> CustomizeControl
Public Event CustomizeControl As EventHandler(Of CustomizeControlEventArgs)
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. |
The following code snippet changes the SimpleAction‘s color in a WinForm application. To run this code, add the DevExpress.ExpressApp.XtraBars.v25.2.dll assembly to References.
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;
}
}
}
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 control is created - call the OnFrameAssigned method instead.
The CustomizeControlEventArgs.Control event parameter returns the Action Item object that contains control settings.
Run Demo: Actions - Simple Action
If you customize a SimpleAction, the e.Control argument can return the following types:
SimpleButton for Layout Actions
BarButtonItem for BarManager Actions
myAction.CustomizeControl += (s, e) => {
SimpleButton control = e.Control as SimpleButton;
// or
BarButtonItem control = e.Control as BarButtonItem;
//...
}
If you customize a SingleChoiceAction, the e.Control argument can return the following types:
ImageComboBoxEdit for Layout Actions
BarEditItem, BarButtonItem, RibbonGalleryBarItem for BarManager Actions
myAction.CustomizeControl += (s, e) => {
ImageComboBoxEdit control = e.Control as ImageComboBoxEdit;
// or
BarEditItem control = e.Control as BarEditItem;
//...
}
If you customize a ShowNavigationItemController.ShowNavigationItemAction, the e.Control argument can return the following types:
NavBarControl if the IModelRootNavigationItems.NavigationStyle property value is NavigationStyle.NavBar
TreeList if the IModelRootNavigationItems.NavigationStyle property is NavigationStyle.TreeList
Frame.GetController<ShowNavigationItemController>().ShowNavigationItemAction.CustomizeControl += (s, e) => {
NavBarControl navBar = e.Control as NavBarControl;
// or
TreeList treeList = e.Control as TreeList;
//...
}
If you customize a ParametrizedAction, the e.Control argument can return the following types:
ButtonEdit descendants (SpinEdit, ButtonEditWithClearButton, and DateEdit) for Layout Actions
BarEditItem for BarManager Actions
myAction.CustomizeControl += (s, e) => {
DateEdit control = e.Control as DateEdit;
// or
BarEditItem control = e.Control as BarEditItem;
//...
}
If you customize a PopupWindowShowAction, the e.Control argument can return the following types:
SimpleButton for Layout Actions
BarButtonItem for BarManager Actions
myAction.CustomizeControl += (s, e) => {
SimpleButton control = e.Control as SimpleButton;
// or
BarButtonItem control = e.Control as BarButtonItem;
//...
}
For detailed information on how to add Actions to Context Menu or Command Column of a List View grid, refer to the following topic: ActionBase.Category.
If you customize a SimpleAction or a PopupWindowShowAction, the e.Control argument can return the following types:
DxToolbarItemSimpleActionControl for Toolbar ActionsDxRibbonItemSimpleActionControl for Ribbon ActionsDxContextMenuItemSimpleActionControl for DxGrid Context Menu ActionsListEditorInlineActionControl for DxGrid Inline ActionsmyAction.CustomizeControl += (s, e) => {
DxToolbarItemSimpleActionControl actionControl = e.Control as DxToolbarItemSimpleActionControl;
// or
DxRibbonItemSimpleActionControl actionControl = e.Control as DxRibbonItemSimpleActionControl;
// or
DxContextMenuItemSimpleActionControl actionControl = e.Control as DxContextMenuItemSimpleActionControl;
// or
ListEditorInlineActionControl actionControl = e.Control as ListEditorInlineActionControl;
//...
}
For information on how to customize an Inline Action in a DxGrid row, refer to the following topic: Customize Inline Action Control (ASP.NET Core Blazor).
If you customize a SingleChoiceAction, the e.Control argument can return the following types:
DxToolbarComboBoxItemSingleChoiceActionControl for non-hierarchical Toolbar Actions with SingleChoiceAction.ItemType.ItemIsModeDxRibbonItemSingleChoiceActionControl or DxRibbonComboBoxItemSingleChoiceActionControl for Ribbon ActionsDxToolbarItemSingleChoiceActionControl for other Toolbar ActionsDxContextMenuItemSingleChoiceActionControl for Context Menu ActionsmyAction.CustomizeControl += (s, e) => {
DxToolbarComboBoxItemSingleChoiceActionControl actionControl = e.Control as DxToolbarComboBoxItemSingleChoiceActionControl;
// or
DxRibbonItemSingleChoiceActionControl actionControl = e.Control as DxRibbonItemSingleChoiceActionControl;
// or
DxToolbarItemSingleChoiceActionControl actionControl = e.Control as DxToolbarItemSingleChoiceActionControl;
// or
DxContextMenuItemSingleChoiceActionControl actionControl = e.Control as DxContextMenuItemSingleChoiceActionControl;
//...
}
If you customize a ParametrizedAction, the e.Control argument returns a DxToolbarItemParametrizedActionControl or DxRibbonItemParametrizedActionControl object.
myAction.CustomizeControl += (s, e) => {
DxToolbarItemParametrizedActionControl actionControl = e.Control as DxToolbarItemParametrizedActionControl;
// or
DxRibbonItemParametrizedActionControl actionControl = e.Control as DxRibbonItemParametrizedActionControl;
//...
}
If you customize a ShowNavigationItemAction, the e.Control argument returns a ShowNavigationItemActionControl object. You can use ShowNavigationItemActionControl.NavigationComponentAdapter to customize the navigation control. The following adapter types are available:
Accordion or NavBarIModelRootNavigationItems.NavigationStyle property value is TreeList.Both component adapter types have the following members:
The Component property contains a reference to the underlying navigation control (DxTreeView or DxAccordion). Use this reference to expand or collapse navigation items.
The ComponentModel property contains the component model that you can use to modify properties of the navigation control.
The ComponentCaptured event fires when the Component property is initialized with a reference to a navigation control.
Frame.GetController<ShowNavigationItemController>().ShowNavigationItemAction.CustomizeControl += (s, e) => {
var navigationComponentAdapter = (e.Control as ShowNavigationItemActionControl)?.NavigationComponentAdapter;
if(navigationComponentAdapter is DxTreeViewAdapter treeViewAdapter) {
// ...
}
else if(navigationComponentAdapter is DxAccordionAdapter accordionAdapter) {
// ...
}
}
Refer to the following topic for more information on how to access control properties: How to: Access the Navigation Control.
See Also