Back to Devexpress

BarItemCollection.Add(String) Method

blazor-devexpress-dot-blazor-dot-office-dot-baritemcollection-dot-add-x28-system-dot-string-x29.md

latest2.7 KB
Original Source

BarItemCollection.Add(String) Method

Adds a predefined item to the ribbon or toolbar.

Namespace : DevExpress.Blazor.Office

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public IBarItem Add(
    string name
)

Parameters

NameTypeDescription
nameString

The item name.

|

Returns

TypeDescription
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:

razor
<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);
    }
}

Run Demo: Toolbar CustomizationRun Demo: Ribbon Customization

See Also

BarItemCollection Class

BarItemCollection Members

DevExpress.Blazor.Office Namespace