aspnet-devexpress-dot-web-dot-navbargroup-74650c36.md
Gets the collection of items within the group and provides indexed access to them.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public NavBarItemCollection Items { get; }
Public ReadOnly Property Items As NavBarItemCollection
| Type | Description |
|---|---|
| NavBarItemCollection |
A NavBarItemCollection object representing the collection of the group’s items.
|
The Items property provides access to a collection that contains all the items of the current group. This collection provides standard means to manipulate (add or remove) items within a group. A particular item can be accessed using index notation.
If you need to obtain a collection that holds all the items of the navbar control, you can use the ASPxNavBar.Items property.
This example demonstrates how to modify the ASPxNavBar‘s group header content.
using DevExpress.Web.ASPxNavBar;
...
protected void Page_Load(object sender, EventArgs e) {
NavBarGroup group1 = new NavBarGroup("group1", "group1");
NavBarItem item1 = new NavBarItem("item1", "item1");
ASPxNavBar1.Groups.Add(group1);
group1.Items.Add(item1);
group1.HeaderTemplate = new MyTemplate();
group1.HeaderTemplateCollapsed = new MyTemplate1();
}
public class MyTemplate : ITemplate {
void ITemplate.InstantiateIn(Control container) {
Label label = new Label();
label.Text = "The group is expanded";
container.Controls.Add(label);
}
}
public class MyTemplate1 : ITemplate {
void ITemplate.InstantiateIn(Control container) {
Label label2 = new Label();
label2.Text = "The group is collapsed";
container.Controls.Add(label2);
}
}
Imports DevExpress.Web.ASPxNavBar
...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim group1 As New NavBarGroup("group1", "group1")
Dim item1 As New NavBarItem("item1", "item1")
ASPxNavBar1.Groups.Add(group1)
group1.Items.Add(item1)
group1.HeaderTemplate = New MyTemplate()
group1.HeaderTemplateCollapsed = New MyTemplate1()
End Sub
Public Class MyTemplate
Implements ITemplate
Private Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
Dim label As New Label()
label.Text = "The group is expanded"
container.Controls.Add(label)
End Sub
End Class
Public Class MyTemplate1
Implements ITemplate
Private Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
Dim label2 As New Label()
label2.Text = "The group is collapsed"
container.Controls.Add(label2)
End Sub
End Class
See Also