MenuItemCollection.FindByText(String) Method
In This Article
Returns an item object with the specified MenuItem.Text property value.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
text | String | A String value representing the Menu |
#Returns
Type | Description |
---|---|
Menu |
A Menu |
#Remarks
Use this method to obtain an item specified by a display text assigned to its MenuItem.Text property.
#Example
The code sample below demonstrates how to populate an ASPxMenu control with items manually, in unbound mode. The image below shows the result.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
CreateMenu();
}
}
//Create Menu initial structure.
void CreateMenu() {
string[] Items = { "Home", "News", "Products", "Client Center" };
foreach (string ItemText in Items) {
MyMenu.Items.Add(ItemText);
}
MyMenu.Items.FindByText("News").Items.Add("Subscriptions");
MenuItem[] ProductsItems = {
new MenuItem("Downloads"),
new MenuItem("Support"),
new MenuItem("Order")
};
MyMenu.Items.FindByText("Products").Items.Add(ProductsItems);
}
//Add a new item
protected void btnAddItem_Click(object sender, EventArgs e) {
if ((MyMenu.SelectedItem != null) && (tbItemName.Text != "")) {
MyMenu.SelectedItem.Items.Add(tbItemName.Text);
}
}
See Also