Explain how to dynamically add items to a menu in .NET
- Menu items can be added at run time by specifying the DynamicItemStart command flag on a placeholder button definition in the Visual Studio command-table (.vsct) file and then defining (in code) the number of menu items to display and handling the command(s).
- When the VSPackage is loaded, the placeholder is replaced with the dynamic menu items.
Example:Let Menu1 be the menu.
MenuItem item1=new MenuItem();
Item1.Text=”item1”;
Item1.value=”one”;
Menu1.Items.Add(item1);