Get a Windows Forms control by name in C#

accessibility, c#, controls, string, winforms

Solution

Use the Control.ControlCollection.Find method.

Try this:

this.Controls.Find()

Problem

I have a `ToolStripMenuItem` called `myMenu`. How can I access this like so: ``` /* Normally, I would do: */ this.myMenu... etc. /* But how do I access it like this: */ String name = myMenu; this.name... ``` This is because I am dynamically generating ToolStripMenuItems from an XML file and need to reference MenuItems by their dynamically generated names.

Original source