Clea all controls at a time in DotNet


 void clear()
    {
        foreach (Control c in form1.Controls)       //This loop takes all controls from the form1
        {
            //Clear all textbox values
            if (c is TextBox)
                ((TextBox)c).Text = "";

            //clear all check boxes
            if (c is CheckBox)
                ((CheckBox)c).Checked = false;

            //Clear all radio buttons
            if (c is RadioButton)
                ((RadioButton)c).Checked = false;
        }
    }

0 comments:

Post a Comment