Back to Devexpress

ASPxNavBar.Groups Property

aspnet-devexpress-dot-web-dot-aspxnavbar.md

latest3.6 KB
Original Source

ASPxNavBar.Groups Property

Gets the collection of groups in NavBar.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public NavBarGroupCollection Groups { get; }
vb
Public ReadOnly Property Groups As NavBarGroupCollection

Property Value

TypeDescription
NavBarGroupCollection

A NavBarGroupCollection object which represents the collection of groups within the navbar.

|

Remarks

The Groups property is used to provide access to the collection of groups within the navbar control. The collection is represented by an instance of the NavBarGroupCollection class and allows individual groups (which are instances of the NavBarGroup class) to be added, deleted and accessed using an indexer notation.

Example

This example demonstrates how to modify the ASPxNavBar‘s group header content.

csharp
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);
     }
}
vb
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

NavBarGroupCollection

NavBarGroup

Navigation Bar

ASPxNavBar Class

ASPxNavBar Members

DevExpress.Web Namespace