Skip to main content
Bar

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

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