I have a ToolStripMenuItem
called myMenu
. How can I access this like so:
/* Normally, I would do: */
this.myMenu... etc.
/* But ho
Since you're generating them dynamically, keep a map between a string and the menu item, that will allow fast retrieval.
// in class scope
private readonly Dictionary _menuItemsByName = new Dictionary();
// in your method creating items
ToolStripMenuItem createdItem = ...
_menuItemsByName.Add("", createdItem);
// to access it
ToolStripMenuItem menuItem = _menuItemsByName[""];