Back to Devexpress

ToolboxControl.InitializeMenu Event

windowsforms-devexpress-dot-xtratoolbox-dot-toolboxcontrol-a8a13d74.md

latest2.7 KB
Original Source

ToolboxControl.InitializeMenu Event

Fires when the ToolboxControl popup menu is about to be shown, and allows you to customize the menu.

Namespace : DevExpress.XtraToolbox

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event ToolboxInitializeMenuEventHandler InitializeMenu
vb
<DXCategory("Events")>
Public Event InitializeMenu As ToolboxInitializeMenuEventHandler

Event Data

The InitializeMenu event's data class is DevExpress.XtraToolbox.ToolboxInitializeMenuEventArgs.

Remarks

The ToolboxControl can display the menu button that invokes the pop-up menu providing quick access to the groups of items. To specify whether the menu button is shown, use the ToolboxOptionsView.ShowMenuButton property. It is also possible to display custom commands in the menu by handling the InitializeMenu event.

The InitializeMenu event is fired before the ToolboxControl pop-up menu is shown. The ToolboxInitializeMenuEventArgs.Menu property returns the DXPopupMenu object that represents the pop-up menu that is about to be displayed.

The code snippet below shows how to add a custom command to the menu.

csharp
private void toolboxControl_InitializeMenu(object sender, ToolboxInitializeMenuEventArgs e) {
    e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Close", (o, args) => this.Close()));
}
vb
Private Sub toolboxControl_InitializeMenu(sender As Object, e As ToolboxInitializeMenuEventArgs)
    e.Menu.Items.Add(New DevExpress.Utils.Menu.DXMenuItem("Close", Function(o, args) Me.Close()))
End Sub

See Also

ShowMenuButton

MenuManager

ToolboxControl Class

ToolboxControl Members

DevExpress.XtraToolbox Namespace