Back to Devexpress

How to: Add an item to a category

windowsforms-5422-controls-and-libraries-ribbon-bars-and-menu-examples-bars-how-to-add-an-item-to-a-category.md

latest783 B
Original Source

How to: Add an item to a category

  • Nov 13, 2018

The following sample code creates a new category and adds it to the BarManager’s BarManager.Categories collection. Then, the category created is assigned to the first item in the BarManager’s BarManager.Items collection.

csharp
if (barManager1.Categories.IndexOf("NewCategory") == -1) {
   barManager1.Items[0].Category = barManager1.Categories.Add("NewCategory");
}
vb
If BarManager1.Categories.IndexOf("NewCategory") = -1 Then
   BarManager1.Items(0).Category = BarManager1.Categories.Add("NewCategory")
End If