How to get the name of menuitem at runtime?

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!
 
S

Shakir Hussain

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.
 
C

Christoph Nahr

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top