Back to Devexpress

BarManagerCategoryCollection.Add(String) Method

windowsforms-devexpress-dot-xtrabars-dot-barmanagercategorycollection-dot-add-x28-system-dot-string-x29.md

latest3.3 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public virtual BarManagerCategory Add(
    string name
)
vb
Public Overridable Function Add(
    name As String
) As BarManagerCategory

Parameters

NameTypeDescription
nameString

A string value specifying the category’s name.

|

Returns

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

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

See Also

AddRange(BarManagerCategory[])

Remove(BarManagerCategory)

Insert(Int32, BarManagerCategory)

IndexOf

BarManagerCategoryCollection Class

BarManagerCategoryCollection Members

DevExpress.XtraBars Namespace