I am trying to find an elegant way to get controls on a Windows Forms form by name. For example:
MyForm.GetControl "MyTextBox"
...
But this has to make sure it goes through all the controls recursively.
What’s the most elegant way to implement this using LINQ?
LINQ isn’t necessarily best-suited to unknown-depth recursion; just use regular code…
with:
Or if you don’t like the recursion above: