

CleanCode.Forms FormExtensions
Namespace: CleanCode.Forms
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
You can do deep searching—searching an entire hierarchy
rather than just immediate children—of Controls and
ToolStripMenuItems
by extending their respective classes with the aptly named All method.
I found the former in the useful, short article entitled
"LINQ - The Uber FindControl" at
http://weblogs.asp.net/dfindley/archive/2007/06/29/linq-the-uber-findcontrol.aspx.
Each method takes as input a collection of the appropriate object and returns an IEnumerable<T> collection of all descendants. In the case of Controls, then, you would typically pass in the collection of direct child Controls placed on a form:
foreach (Control c in myForm.Controls.All()) . . .
foreach (ToolStripMenuItem item in ContextMenuStrip.Items.All()) . . .
Since CleanCode 0.9.26.