diff --git a/X10D.WinForms/ControlExtensions.cs b/X10D.WinForms/ControlExtensions.cs
index 7155cc9..efbf640 100644
--- a/X10D.WinForms/ControlExtensions.cs
+++ b/X10D.WinForms/ControlExtensions.cs
@@ -2,6 +2,9 @@
{
#region Using Directives
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
using System.Windows.Forms;
#endregion
@@ -11,6 +14,43 @@
///
public static class ControlExtensions
{
+ ///
+ /// Gets all controls and child controls of a specified control.
+ ///
+ /// The parent control.
+ /// Returns a collection of controls.
+ public static IEnumerable GetAllControls(this Control control)
+ {
+ return control.GetAllControls();
+ }
+
+ ///
+ /// Gets all controls and child controls of a specified control, which match the specified type.
+ ///
+ /// A type.
+ /// The parent control.
+ /// Returns a collection of controls.
+ public static IEnumerable GetAllControls(this Control control)
+ where TControl : Control
+ {
+ return control.GetAllControls(typeof(TControl)).Cast();
+ }
+
+ ///
+ /// Gets all controls and child controls of a specified control, which match the specified type.
+ ///
+ /// The parent control.
+ /// The type to match.
+ /// Returns a collection of controls.
+ public static IEnumerable GetAllControls(this Control control, Type type)
+ {
+ IEnumerable controls = control.Controls.Cast().ToArray();
+
+ return controls.SelectMany(c => GetAllControls(c, type))
+ .Concat(controls)
+ .Where(c => c.GetType() == type);
+ }
+
///
/// Thread-safe method invocation. Calls if
/// returns .
diff --git a/X10D.WinForms/README.md b/X10D.WinForms/README.md
index b7ac71b..f85ed99 100644
--- a/X10D.WinForms/README.md
+++ b/X10D.WinForms/README.md
@@ -8,5 +8,5 @@ Below is a list of the number of extension methods written for a given type. Ove
| Type | Library | Method count |
| :--- | :--- | :--- |
-| `Control` | `X10D.WinForms` | 1 |
+| `Control` | `X10D.WinForms` | 2 |
| `ListViewItem` | `X10D.Unity` | 1 |