I was watching a tutorial video on the MenuStrip control for WindowsForms and the video provided by MSDN site indicates you could reference a specific menu item using a “key” rather than an index number – but they never explained how and a quick search yielded me with no results.
How can you reference a menu item by its name rather than an index number (which can change if you add new menu items) ?
It is the same way as the index. Just provide a
stringrepresenting the name of the menu item instead of the known index of the item. This is known as thekeyvalue.index Example:
string Example: