ActionBase.CustomizeControl Event
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
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 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.
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.NavigationStyleproperty 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:
DxToolbarItemSimpleActionControlfor Toolbar ActionsDxRibbonItemSimpleActionControlfor Ribbon ActionsDxContextMenuItemSimpleActionControlfor DxGrid Context Menu ActionsListEditorInlineActionControlfor DxGrid Inline Actions
myAction.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).
Single Choice Actions
If you customize a SingleChoiceAction, the e.Control argument can return the following types:
DxToolbarComboBoxItemSingleChoiceActionControlfor non-hierarchical Toolbar Actions with SingleChoiceAction.ItemType.ItemIsModeDxRibbonItemSingleChoiceActionControlorDxRibbonComboBoxItemSingleChoiceActionControlfor Ribbon ActionsDxToolbarItemSingleChoiceActionControlfor other Toolbar ActionsDxContextMenuItemSingleChoiceActionControlfor Context Menu Actions
myAction.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;
//...
}
Parametrized Actions
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;
//...
}
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
AccordionorNavBar - DxTreeViewAdapter if the
IModelRootNavigationItems.NavigationStyleproperty value isTreeList.
Both component adapter types have the following members:
- The
Componentproperty contains a reference to the underlying navigation control (DxTreeView or DxAccordion). Use this reference to expand or collapse navigation items. - The
ComponentModelproperty contains the component model that you can use to modify properties of the navigation control. - The
ComponentCapturedevent fires when theComponentproperty 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.