Users Pricing

forum

Home Forums How to find controls in winforms c# – MindStick

How to find controls in winforms c#

Anonymous User 4342 22 Jan 2014

I need to find controls in my forms. In asp.net I used Recursive method to do it, now how to do in winforms?

public static Control FindControlRecursive(Control root, string id)
{
    if (root.ID == id)
        return root;
    return root.Controls.Cast<Control>()
       .Select(c => FindControlRecursive(c, id))
       .FirstOrDefault(c => c != null);
}

any idea..thanks...


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md