How to get the name of menuitem at runtime?

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

like this,
foreach (MenuItem item in this.mainMenu1.MenuItems)
{
//some code
//I want to get the menuitem's name here!

}
No name property found. please help!
 
Like other controls Name property is not available for use.

Couple of recomendations

1. While constructing the menu, create a hashtable.

2. Derive a class from menuitem and add your own properties to store menu
name.

Shak.
 
Like other controls Name property is not available for use.

MenuItem is just a component, not a control -- that's why it doesn't
have a "real" Name property. The Name property of real controls is
certainly available for use from outside the designer.
2. Derive a class from menuitem and add your own properties to store menu
name.

Yes, that's perhaps the best approach.
 
Back
Top