Articles in this section
Category / Section

How to add MenuItem, programmically to the Menu control?

1 min read

Description:

Programmatically, you can add the Menu Item, by defining and adding an object of MenuItem class to the Menu control.

Solution:

To add the Menu Item in a Menu control, you need to do the following things:

  1. Define properties of the Menu Item object, like Id, Text and ParentId with help of MenuItem class.
  2. Add the defined item object to the Menu control using the AddItem() method.

Refer the following code example.

C#               

MenuItem root=new MenuItem();
root=Menu1.GetItemByID("Root1");
MenuItem newItem=new MenuItem();
newItem.Text="ChildItem";
root.Items.AddItem(newItem);  

VB               

Private root As MenuItem = New MenuItem()
Private root=Menu1.GetItemByID("Root1")
Private newItem As MenuItem = New MenuItem()
Private newItem.Text="ChildItem"
root.Items.AddItem(newItem) 

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied