Skip to main content
A newer version of this page is available. .
All docs
V20.2
Tab

ASPxGridView.ContextMenuInitialize Event

Occurs when the context menu is initialized.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

NuGet Package: DevExpress.Web

Declaration

public event ASPxGridViewContextMenuInitializeEventHandler ContextMenuInitialize

Event Data

The ContextMenuInitialize event's data class is ASPxGridViewContextMenuInitializeEventArgs. The following properties provide information specific to this event:

Property Description
ContextMenu Gets the context menu.
MenuType Gets the context menu type.

The event data class exposes the following methods:

Method Description
CreateItem(GridViewContextMenuCommand) Creates a new context menu item.
CreateItem(String, String) Creates a new context menu item.

Remarks

You can use the ContextMenuInitialize event to customize the context menu when it is initialized.

The following example illustrates how to add a new context menu item when a user right clicks a grid row (MenuType):

<dx:ASPxGridView ID="Grid" OnContextMenuInitialize="Grid_ContextMenuInitialize"
    OnContextMenuItemClick="Grid_ContextMenuItemClick">
    <SettingsContextMenu>
        <RowMenuItemVisibility>
            <ExportMenu Visible="true" />
        </RowMenuItemVisibility>
    </SettingsContextMenu>
</dx:ASPxGridView>
protected void Grid_ContextMenuInitialize(object sender, ASPxGridViewContextMenuInitializeEventArgs e) {
    if(e.MenuType == GridViewContextMenuType.Rows) {
        var exportMenuItem = e.ContextMenu.Items.FindByCommand(GridViewContextMenuCommand.ExportMenu);
        exportMenuItem.Items.Add("Custom export to XLS(WYSIWYG)", "CustomExportToXLS").Image.IconID = "export_exporttoxls_16x16";
    }
}

Result:

Online Demo

See Also