Initialize Controls

You can write a new method to reset the controls and then call it in the method "Submit_Click".

private void Reset()
{
    checkBox1.CheckState = CheckState.Unchecked;
    checkBox2.CheckState = CheckState.Unchecked;
    // ...
    textBox1.Text = string.Empty;
    textBox2.Text = string.Empty;
    // ...
}

private void Submit_Click(object sender, EventArgs e)
{
    // any other operation, like saving/renaming a file
    Reset();
}

If you want to initialize all controls, you can use the following code to implement it.

private void Submit_Click(object sender, EventArgs e)
{
    // any other operation, like saving/renaming a file
    Controls.Clear();
    InitializeComponent();
}
原文地址:https://www.cnblogs.com/jizhiqiliao/p/9881704.html