ActionBase.CustomizeControl Event
Fires after the control is initialized. Allows you to customize the control.
Namespace: DevExpress.ExpressApp.Actions
Assembly: DevExpress.ExpressApp.v22.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.v22.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
The SimpleAction returns the following value type:
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
The ShowNavigationItem
Action returned by the ShowNavigationItemController.ShowNavigationItemAction property have the following returned value’s type:
- 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
The ParametrizedAction returns the ParametrizedActionMenuActionItem
value type.
myAction.CustomizeControl += (s, e) => {
ParametrizedActionMenuActionItem actionItem = e.Control as ParametrizedActionMenuActionItem;
//...
}
PopupWindowShow Actions
The (xref:DevExpress.ExpressApp.Actions.PopupWindowShowAction) returns the following value’s 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
The SimpleAction returns the following value’s type:
- 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
The SingleChoiceAction returns the following value 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
The ShowNavigationItem
Action returned by the ShowNavigationItemController.ShowNavigationItemAction property have the following returned value type:
- 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
The ParametrizedAction returns the following value 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
The (xref:DevExpress.ExpressApp.Actions.PopupWindowShowAction) returns the following value 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
Simple Actions
The SimpleAction returns the DxToolbarItemSimpleActionControl
value type.
myAction.CustomizeControl += (s, e) => {
DxToolbarItemSimpleActionControl actionControl = e.Control as DxToolbarItemSimpleActionControl;
//...
}
Single Choice Actions
The SingleChoiceAction returned value type depends on the SingleChoiceAction.ItemType property value and ChoiceActionItems
child items:
DxToolbarComboBoxItemSingleChoiceActionControl
DxToolbarItemSingleChoiceActionControl
myAction.CustomizeControl += (s, e) => {
DxToolbarComboBoxItemSingleChoiceActionControl actionControl = e.Control as DxToolbarComboBoxItemSingleChoiceActionControl;
// or
DxToolbarItemSingleChoiceActionControl actionControl = e.Control as DxToolbarItemSingleChoiceActionControl;
//...
}
ShowNavigationItem Actions
The ShowNavigationItemAction returns the ShowNavigationItemActionControl
value type. 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
.
The both component adapter types expose the following API:
- The
Component
property contains a reference to the underlying navigation control (DxTreeView or DxAccordion). You can 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.
Parametrized Actions
The ParametrizedAction returns the DxToolbarItemParametrizedActionControl
value type.
myAction.CustomizeControl += (s, e) => {
DxToolbarItemParametrizedActionControl actionControl = e.Control as DxToolbarItemParametrizedActionControl;
//...
}
PopupWindowShow Actions
The PopupWindowShowAction returns the DxToolbarItemSimpleActionControl
value type.
myAction.CustomizeControl += (s, e) => {
DxToolbarItemSimpleActionControl actionControl = e.Control as DxToolbarItemSimpleActionControl;
//...
}
Related GitHub Examples
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.