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();
}
posted @ 2018-10-31 10:44  Kyle0418  阅读(140)  评论(0编辑  收藏  举报