RemoveSpreadsheetCommandAction Class
An action that removes a bar item associated with a specific Spreadsheet command. This action also deletes all links to this bar item from bars, menus, submenus, and other link holders.
Namespace: DevExpress.Xpf.Spreadsheet.Menu
Assembly: DevExpress.Xpf.Spreadsheet.v26.1.dll
NuGet Package: DevExpress.Wpf.Spreadsheet
Declaration
Remarks
Add a RemoveSpreadsheetCommandAction instance to the PopupMenuShowingEventArgs.Customizations collection to remove command links for the command defined by the RemoveSpreadsheetCommandAction.Id property.
RemoveSpreadsheetCommandAction removes a bar item from the BarManager.Items collection and deletes all links to the bar item from link holders (bars, ribbon, menus, and so on).
Example
The example below customizes the Cell context menu as follows:
- Creates new Merge Cells and Highlight Cells items
- Removes the Insert Comment and Hyperlink items

<dxsps:SpreadsheetControl x:Name="spreadsheetControl"
PopupMenuShowing="spreadsheetControl_PopupMenuShowing"/>
using DevExpress.Xpf.Bars;
using DevExpress.Xpf.Spreadsheet;
using DevExpress.Xpf.Spreadsheet.Menu;
using DevExpress.XtraSpreadsheet.Commands;
// ...
private void spreadsheetControl_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
// Check whether the event is raised for a spreadsheet cell.
if (e.MenuType == SpreadsheetMenuType.Cell) {
// Create a menu item to merge selected cells
// and bind this item to the spreadsheet command.
e.Customizations.Add(new BarButtonItem() {
Command = SpreadsheetUICommand.EditingMergeAndCenterCells,
Content = "Merge Cells",
CommandParameter = spreadsheetControl
});
// Create a custom menu item to highlight selected cells.
var menuItem = new BarButtonItem();
menuItem.Name = "highlightCellsItem";
menuItem.Content = "Highlight Cells";
menuItem.ItemClick += MenuItem_ItemClick;
e.Customizations.Add(menuItem);
}
// Remove the "Insert Comment" item from the menu.
e.Customizations.Add(new RemoveSpreadsheetCommandAction() {
Id = SpreadsheetCommandId.ReviewInsertCommentContextMenuItem
});
// Remove the "Hyperlink" item from the menu.
e.Customizations.Add(new RemoveSpreadsheetCommandAction() {
Id = SpreadsheetCommandId.InsertHyperlinkContextMenuItem
});
}
private void MenuItem_ItemClick(object sender, ItemClickEventArgs e) {
// Fill selected cells with the yellow color.
spreadsheetControl.Selection.FillColor = System.Drawing.Color.Yellow;
}