I am creating a windows form applicaiton. I have a scenario where I need to clear all text boxes. Is there any easy way to do that? Rather than doing it one by one?

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

answered by (171 points)
selected by
+1 vote
Best answer
This function worked for me.


private void ClearTextBoxes()
            Action<Control.ControlCollection> func = null;

            func = (controls) =>
                foreach (Control control in controls)
                    if (control is TextBox)
                        (control as TextBox).Clear();