NavBarGroupCollection.FindByText(String) Method
Returns a group object with the specified NavBarGroup.Text property value.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Parameters
Name | Type | Description |
---|---|---|
text | String | A String value representing the NavBarGroup.Text property value of the required group. |
Returns
Type | Description |
---|---|
NavBarGroup | A NavBarGroup object with a specific value of the NavBarGroup.Text property. |
Remarks
Use this method to obtain a group specified by a display text assigned to its NavBarGroup.Text property.
Example
The code sample below demonstrates how to populate an ASPxNavBar control with groups and items manually, in unbound mode. The image below shows the result.
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
CreateNavBar();
}
}
//Create NavBar initial structure.
void CreateNavBar() {
string[] GroupTexts = { "Home", "News", "Products", "Client Center" };
foreach (string Text in GroupTexts) {
MyASPxNavBar.Groups.Add(Text);
}
MyASPxNavBar.Groups.FindByText("News").Items.Add("Subscriptions");
NavBarItem[] ProductsItems = {
new NavBarItem("Downloads"),
new NavBarItem("Support"),
new NavBarItem("Order")
};
MyASPxNavBar.Groups.FindByText("Products").Items.Add(ProductsItems);
}
//Add a new group
protected void btnAddGroup_Click(object sender, EventArgs e) {
if (tbItemName.Text != "") {
MyASPxNavBar.Groups.Add(tbItemName.Text);
}
}
//Add a new item
protected void btnAddItem_Click(object sender, EventArgs e) {
if ((MyASPxNavBar.ActiveGroup != null) && (tbItemName.Text != "")) {
MyASPxNavBar.ActiveGroup.Items.Add(tbItemName.Text);
}
}
See Also