Back to Devexpress

IContextMenuItemCollection.Remove(Int32) Method

blazor-devexpress-dot-blazor-dot-icontextmenuitemcollection-dot-remove-x28-system-dot-int32-x29.md

latest2.9 KB
Original Source

IContextMenuItemCollection.Remove(Int32) Method

Removes an item with the specified index from an item collection.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
bool Remove(
    int index
)

Parameters

NameTypeDescription
indexInt32

Item index.

|

Returns

TypeDescription
Boolean

true if the item is removed; otherwise, false.

|

Remarks

Handle the CustomizeContextMenu event to modify context commands available in the Grid, Rich Text Editor, or TreeList component. In the event handler, call the Remove method to remove an item from the menu item collection.

The following code snippet removes items from the main context menu:

razor
<DxRichEdit CustomizeContextMenu="OnCustomizeContextMenu"/>

@code {
    void OnCustomizeContextMenu(IContextMenuItemCollection items) {
        // Removes the first item
        items.Remove(0);
        // Removes the "Decrease Indent" item
        items.Remove(RichEditContextMenuItemNames.DecreaseIndent);
    }
}
razor
<DxGrid ContextMenus="GridContextMenus.All" CustomizeContextMenu="CustomizeContextMenu">
    @* ... *@
</DxGrid>

@code {
    void CustomizeContextMenu(GridCustomizeContextMenuEventArgs args) {
        // Removes the first item
        args.Items.Remove(0);
        // Removes the "Sort Ascending" item
        args.Items.Remove(GridContextMenuDefaultItemNames.SortColumnAscending);
    }
}
razor
<DxTreeList ContextMenus="TreeListContextMenus.All" CustomizeContextMenu="CustomizeContextMenu">
    @* ... *@
</DxTreeList>

@code {
    void CustomizeContextMenu(TreeListCustomizeContextMenuEventArgs args) {
        // Removes the first item
        args.Items.Remove(0);
        // Removes the "Sort Ascending" item
        args.Items.Remove(TreeListContextMenuDefaultItemNames.SortColumnAscending);
    }
}

Refer to CustomizeContextMenu event descriptions for additional information and examples:

See Also

IContextMenuItemCollection Interface

IContextMenuItemCollection Members

DevExpress.Blazor Namespace