A newer version of this page is available. Switch to the current version.

RichEditControl.PopupMenuShowing Event

Occurs before a popup menu is created for the control’s document every time a context menu is being invoked.

Namespace: DevExpress.Xpf.RichEdit

Assembly: DevExpress.Xpf.RichEdit.v19.1.dll


public event PopupMenuShowingEventHandler PopupMenuShowing

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 displayed in the RichEditControl.
MenuType Gets a visual element for which the popup menu is invoked.


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


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

Handle the RichEditControl.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 RemoveRichEditCommandAction 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.

private void RichEditPopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
        if ((e.MenuType & RichEditMenuType.TableCell) != 0) {

        // Remove the unnecessary buit-in items by their indices.
        for (int i = e.Menu.Items.Count - 1; i >= 14; i--) {

        // Remove the "Cut" and "Copy" menu items.
        e.Customizations.Add(new RemoveRichEditCommandAction() { Id = RichEditCommandId.CutSelection});
        e.Customizations.Add(new RemoveRichEditCommandAction() { Id = RichEditCommandId.CopySelection });
        // Create a menu item for the RichEdit command, which invokes the Insert Picture dialog.
        e.Customizations.Add(new BarButtonItem() {
            Command = RichEditUICommand.InsertPicture,
            Content = "Insert Picture",
            CommandParameter = richEdit

        // Create a custom menu item and handle its click event.
        BarButtonItem menuItem = new BarButtonItem();
        menuItem.Name = "customHighlightItem";
        menuItem.Content = "Highlight Selection";
        menuItem.ItemClick += new ItemClickEventHandler(customHighlightItem_ItemClick);

private void customHighlightItem_ItemClick(object sender, ItemClickEventArgs e) {
    CharacterProperties charProps = richEdit.Document.BeginUpdateCharacters(richEdit.Document.Selection);
    charProps.BackColor = System.Drawing.Color.Yellow;
See Also