Skip to main content
Bar

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

BarManagerCategoryCollection.Add(String) Method

Creates a new category with the specified name and adds it to the end of the collection.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

public virtual BarManagerCategory Add(
    string name
)

#Parameters

Name Type Description
name String

A string value specifying the category’s name.

#Returns

Type Description
BarManagerCategory

A BarManagerCategory object representing the new category.

#Remarks

The category’s BarManagerCategory.Name property is set to the specified name. Other category settings are set to their default values. Note that the category’s name should be unique, because if the category’s name is the same as that of an existing category, an argument exception will be raised.

To add several categories at once, see the BarManagerCategoryCollection.AddRange method.

#Example

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.

if (barManager1.Categories.IndexOf("NewCategory") == -1) {
   barManager1.Items[0].Category = barManager1.Categories.Add("NewCategory");
}
See Also