windowsforms-devexpress-dot-xtrabars-dot-barmanagercategorycollection-dot-add-x28-system-dot-string-x29.md
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
public virtual BarManagerCategory Add(
string name
)
Public Overridable Function Add(
name As String
) As BarManagerCategory
| Name | Type | Description |
|---|---|---|
| name | String |
A string value specifying the category’s name.
|
| Type | Description |
|---|---|
| BarManagerCategory |
A BarManagerCategory object representing the new category.
|
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.
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");
}
If BarManager1.Categories.IndexOf("NewCategory") = -1 Then
BarManager1.Items(0).Category = BarManager1.Categories.Add("NewCategory")
End If
See Also
AddRange(BarManagerCategory[])
Insert(Int32, BarManagerCategory)
BarManagerCategoryCollection Class