Clear Control using panel

NOTE : you have just take all controls in panel.
Call this method in clear button event. pass that panel in method argument




public void Control(System.Windows.Forms.Panel Pan)
{
    foreach (System.Windows.Forms.Control ctl in Pan.Controls)
    {
        if (ctl.GetType().ToString().Contains("TextBox"))
        {
            ((System.Windows.Forms.TextBox)ctl).Clear();
        }
        if (ctl.GetType().ToString().Contains("ComboBox"))
        {
            ((System.Windows.Forms.ComboBox)ctl).SelectedIndex = -1;
        }
    }
}

No comments: