ActionBase.CustomizeControl Event
Fires after the control is initialized. Allows you to customize the control.
Namespace: DevExpress.ExpressApp.Actions
Assembly: DevExpress.ExpressApp.v24.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. To run this code, add the DevExpress.ExpressApp.XtraBars.v24.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.
ASP.NET Web Forms Specific Scenarios
Simple Actions
If you customize a SimpleAction, the e.Control
argument can return the following types:
SimpleActionMenuActionItem
for menu Actions- ASPxGridViewCustomButtonInitializer for Inline Grid Actions
myAction.CustomizeControl += (s, e) => {
SimpleActionMenuActionItem actionItem = e.Control as SimpleActionMenuActionItem;
// or
ASPxGridViewCustomButtonInitializer initializer = e.Control as ASPxGridViewCustomButtonInitializer;
//...
}
Single Choice Menu Actions
The type of the value the SingleChoiceAction returns depends on the SingleChoiceAction.ItemType property value and ChoiceActionItem child 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 Actions
If you customize a ShowNavigationItemController.ShowNavigationItemAction, the e.Control
argument can return the following types:
- ASPxNavBar if the IModelRootNavigationItems.NavigationStyle property value is NavigationStyle.NavBar
- ASPxTreeView if the
IModelRootNavigationItems.NavigationStyle
property is NavigationStyle.TreeList
Frame.GetController<ShowNavigationItemController>().ShowNavigationItemAction.CustomizeControl += (s, e) => {
ASPxNavBar navBar = e.Control as ASPxNavBar;
// or
ASPxTreeView treeView = e.Control as ASPxTreeView;
//...
}
Parametrized Actions
If you customize a ParametrizedAction, the e.Control
argument returns a ParametrizedActionMenuActionItem
object.
myAction.CustomizeControl += (s, e) => {
ParametrizedActionMenuActionItem actionItem = e.Control as ParametrizedActionMenuActionItem;
//...
}
PopupWindowShow Actions
If you customize a PopupWindowShowAction, the e.Control
argument can return the following types:
PopupWindowActionMenuActionItem
for menu Actions- ASPxGridViewCustomButtonInitializer for Inline Grid Actions
myAction.CustomizeControl += (s, e) => {
PopupWindowActionMenuActionItem actionItem = e.Control as PopupWindowActionMenuActionItem;
// or
ASPxGridViewCustomButtonInitializer actionItem = e.Control as ASPxGridViewCustomButtonInitializer;
//...
}
WinForms Specific Scenarios
Simple Actions
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;
//...
}
Single Choice Actions
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;
//...
}
ShowNavigationItem Actions
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;
//...
}
Parametrized Actions
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;
//...
}
PopupWindowShow Actions
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;
//...
}
ASP.NET Core Blazor Specific Scenarios
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.
Simple and PopupWindowShow Actions
If you customize a SimpleAction or a PopupWindowShowAction, the e.Control
argument can return the following types:
DxToolbarItemSimpleActionControl
for Toolbar ActionsDxContextMenuItemSimpleActionControl
for DxGrid Context Menu ActionsListEditorInlineActionControl
for DxGrid Inline Actions
myAction.CustomizeControl += (s, e) => {
DxToolbarItemSimpleActionControl actionControl = e.Control as DxToolbarItemSimpleActionControl;
// 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).
Single Choice Actions
If you customize a SingleChoiceAction, the e.Control
argument can return the following types:
DxToolbarComboBoxItemSingleChoiceActionControl
for non-hierarchical Toolbar Actions with SingleChoiceAction.ItemType.ItemIsModeDxToolbarItemSingleChoiceActionControl
for other Toolbar ActionsDxContextMenuItemSingleChoiceActionControl
for Context Menu Actions
myAction.CustomizeControl += (s, e) => {
DxToolbarComboBoxItemSingleChoiceActionControl actionControl = e.Control as DxToolbarComboBoxItemSingleChoiceActionControl;
// or
DxToolbarItemSingleChoiceActionControl actionControl = e.Control as DxToolbarItemSingleChoiceActionControl;
// or
DxContextMenuItemSingleChoiceActionControl actionControl = e.Control as DxContextMenuItemSingleChoiceActionControl;
//...
}
Parametrized Actions
If you customize a ParametrizedAction, the e.Control
argument returns a DxToolbarItemParametrizedActionControl
object.
myAction.CustomizeControl += (s, e) => {
DxToolbarItemParametrizedActionControl actionControl = e.Control as DxToolbarItemParametrizedActionControl;
//...
}
ShowNavigationItem Actions
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:
- DxAccordionAdapter if the IModelRootNavigationItems.NavigationStyle property value is
Accordion
orNavBar
- DxTreeViewAdapter if the
IModelRootNavigationItems.NavigationStyle
property value isTreeList
.
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 theComponent
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.