Skip to main content
A newer version of this page is available. .

RemoveSpreadsheetCommandAction Class

An action that removes the bar item associated with a certain Spreadsheet command and removes all links to this bar item from bars, submenus, menus and other link holders.

Namespace: DevExpress.Xpf.Spreadsheet.Menu

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

NuGet Packages: DevExpress.WindowsDesktop.Wpf.Spreadsheet, DevExpress.Wpf.Spreadsheet

Declaration

public class RemoveSpreadsheetCommandAction :
    RemoveBarItemLinkAction

Remarks

Add the RemoveSpreadsheetCommandAction instance to the SpreadsheetControl.MenuCustomizations or the PopupMenuShowingEventArgs.Customizations collection to remove the command links for the command specified by the RemoveSpreadsheetCommandAction.Id property.

This action removes a bar item from the BarManager.Items collection, and removes all links to this bar item from link holders in the UI (bars, Ribbon and menus).

Example

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.

View Example

<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>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RemoveSpreadsheetCommandAction class.

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.

Implements

See Also