Skip to main content

BarItemCollection.Add(Int32, String) Method

Adds a predefined item to the specified position in the ribbon or toolbar.

Namespace: DevExpress.Blazor.Office

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public IBarItem Add(
    int index,
    string name
)

Parameters

Name Type Description
index Int32

The position where to insert the item.

name String

The item name.

Returns

Type Description
IBarItem

The inserted bar item.

Remarks

The Add method overloads allow you to add a predefined item to a ribbon or toolbar group. Use the RichEditBarItemNames class properties to obtain names of all built-in items.

The following code snippet customizes the ribbon as follows:

<DxRichEdit CustomizeRibbon=OnCustomizeRibbon />

@code {
    void OnCustomizeRibbon(IRibbon ribbon) {
        IRibbonTab insertTab = ribbon.Tabs[RichEditRibbonTabNames.Insert];
        IBarGroup group = insertTab.Groups[RichEditRibbonGroupNames.InsertHeaderAndFooter];
        // Inserts the Insert Time Field item at the end of the item collection
        group.Items.Add(RichEditBarItemNames.InsertTimeField);
        // Inserts the Insert Date Field item at the first position in the item collection
        group.Items.Add(0, RichEditBarItemNames.InsertDateField);
    }
}

Add Default Items

Run Demo: Toolbar Customization Run Demo: Ribbon Customization

See Also