You Tube

Thursday 5 January 2017

How to clear all text Boxes in c#?

Put this function in your source code and call from somewhere it's needed.
private void clear_txt_boxes()
        {
            Action<Control.ControlCollection> func = null;

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

            func(Controls);
        }

No comments:

Post a Comment