SpreadsheetControl.PopupMenuShowing Event

Occurs before a popup menu is created for the control's document whenever a context menu is being invoked.

Namespace: DevExpress.Xpf.Spreadsheet

Assembly: DevExpress.Xpf.Spreadsheet.v20.1.dll

Declaration

public event EventHandler<PopupMenuShowingEventArgs> PopupMenuShowing
Public Event PopupMenuShowing As EventHandler(Of PopupMenuShowingEventArgs)

Event Data

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

Property Description
Customizations Provides access to a collection of customizations of the popup menu.
Menu Gets or sets the popup menu for which the SpreadsheetControl.PopupMenuShowing event was raised.
MenuType Indicates a visual element for which the popup menu is invoked.

Remarks

Handle the PopupMenuShowing event to modify items in the context menu. The current context menu can be accessed via the PopupMenuShowingEventArgs.Menu property.

Examples

This example demonstrates how to customize the SpreadsheetControl's context menu - remove the existing menu items and add new items.

Handle the SpreadsheetControl.PopupMenuShowing event. Use the PopupMenuShowingEventArgs.MenuType property to determine the visual element for which the popup menu is invoked.

To remove a menu item, create the RemoveSpreadsheetCommandAction object, set its ID to the ID of the command to remove and add that object to the PopupMenuShowingEventArgs.Customizations collection.

To add a new menu item, create a new BarButtonItem and add it to the PopupMenuShowingEventArgs.Customizations collection.

<dxb:BarManager x:Name="barManager1" ToolbarGlyphSize="Small">
    <dxb:BarManager.Items>
        <dxb:BarButtonItem
            x:Name="customNewFile"
            Command="{Binding FileNew, Mode=OneTime, Source={StaticResource commands}}"
            Content="Custom Create New File" />
        <dxb:BarButtonItem
            x:Name="customMergeCells"
            Command="{Binding EditingMergeAndCenterCells, Mode=OneTime, Source={StaticResource commands}}"
            Content="Custom Merge Cells" />
    </dxb:BarManager.Items>
    <Grid>
        <dxsps:SpreadsheetControl
            x:Name="spreadsheetControl1"
            BarManager="{Binding ElementName=barManager1, Mode=OneTime}"
            PopupMenuShowing="SpreadsheetControlPopupMenuShowing">
            <dxsps:SpreadsheetControl.MenuCustomizations>
                <dxsps:SpreadsheetMenuCustomization MenuType="Cell">
                    <dxb:BarButtonItemLink dxb:BarItemLinkActionBase.ItemLinkIndex="0">
                        <dxb:BarButtonItemLink.BarItemName>
                            customMergeCells
                        </dxb:BarButtonItemLink.BarItemName>
                    </dxb:BarButtonItemLink>
                </dxsps:SpreadsheetMenuCustomization>
                <dxsps:SpreadsheetMenuCustomization>
                    <dxb:BarButtonItemLink dxb:BarItemLinkActionBase.ItemLinkIndex="1">
                        <dxb:BarButtonItemLink.BarItemName>
                            customNewFile
                        </dxb:BarButtonItemLink.BarItemName>
                    </dxb:BarButtonItemLink>
                </dxsps:SpreadsheetMenuCustomization>
                <dxsps:SpreadsheetMenuCustomization>
                    <dxb:BarItemLinkSeparator dxb:BarItemLinkActionBase.ItemLinkIndex="2" />
                </dxsps:SpreadsheetMenuCustomization>
                <dxsps:SpreadsheetMenuCustomization MenuType="ColumnHeading">
                    <dxsps:RemoveSpreadsheetCommandAction 
                        Id="{x:Static dxspscore:SpreadsheetCommandId.HideColumnsContextMenuItem}" />
                    <dxsps:RemoveSpreadsheetCommandAction 
                        Id="{x:Static dxspscore:SpreadsheetCommandId.UnhideColumnsContextMenuItem}" />
                </dxsps:SpreadsheetMenuCustomization>
            </dxsps:SpreadsheetControl.MenuCustomizations>
        </dxsps:SpreadsheetControl>
    </Grid>
</dxb:BarManager>
See Also