Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

IContextMenuItemCollection Interface

A collection of root-level or nested items of the context menu in the Rich Text Editor.

Namespace: DevExpress.Blazor.Office

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public interface IContextMenuItemCollection :
    IEnumerable<IContextMenuItem>,
    IEnumerable

The following members return IContextMenuItemCollection objects:

#Remarks

Use the IContextMenuItemCollection interface members to perform the following operations:

The following code snippet operates with item collections in the CustomizeContextMenu event handler:

Razor
<DxRichEdit CustomizeContextMenu=OnCustomizeContextMenu />

@code {
    void OnCustomizeContextMenu(IContextMenuItemCollection items) {
        // Inserts a custom item at the first position in the item collection
        var searchItem = items.AddCustomItem(0, "Google Search...", ...);
        var openHyperlinkItem = items[RichEditContextMenuItemNames.OpenHyperlink];
        openHyperlinkItem.BeginGroup = false;
        // Gets the built-in item's position in the item collection
        var index = items.IndexOf(openHyperlinkItem);
        // Inserts a custom item at the specified position in the main menu's item collection
        var showURLItem = items.AddCustomItem(index, "Show URL", ...);
        showURLItem.BeginGroup = true;
        // Removes built-in items from the item collection
        items.Remove(RichEditContextMenuItemNames.CutSelection);
        items.Remove(RichEditContextMenuItemNames.CopySelection);
        items.Remove(RichEditContextMenuItemNames.Paste);
        // Inserts a custom item at the second position in the item collection
        var clipboardItem = items.AddCustomItem(1, "Clipboard");
        clipboardItem.BeginGroup = true;
        // Adds default items to the item collection of the inserted item
        clipboardItem.Items.Add(RichEditContextMenuItemNames.CutSelection);
        clipboardItem.Items.Add(RichEditContextMenuItemNames.CopySelection);
        clipboardItem.Items.Add(RichEditContextMenuItemNames.Paste);
    }
}

customize-contextmenu-items

Run Demo: Context Menu Customization

See Also