blazor-devexpress-dot-blazor-dot-office-dot-baritemcollection-dot-add-x28-system-dot-int32-system-dot-string-x29.md
Adds a predefined item to the specified position in the ribbon or toolbar.
Namespace : DevExpress.Blazor.Office
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
public IBarItem Add(
int index,
string name
)
| Name | Type | Description |
|---|---|---|
| index | Int32 |
The position where to insert the item.
| | name | String |
The item name.
|
| Type | Description |
|---|---|
| IBarItem |
The inserted bar item.
|
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);
}
}
Run Demo: Toolbar CustomizationRun Demo: Ribbon Customization
See Also