Skip to main content
All docs
V24.2

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

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:

<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