I'd like to restart my main form on clicking a button. For instance:
In program.cs:
Application.Run(new MainForm(data))
In MainForm.cs:
private void btn1_Click(object sender, EventArgs e)
{
MainForm newForm = new MainForm(newData);
this.close();
Application.Run(newForm);
}
So that my new Main window is the new instance of MainForm. How can I do that in a way such that the first instance is cleared from memory?
EDIT
I.e. I'd like my first instance of MainForm to completely disappear - is that the same as just calling this.Hide()? Or calling this.Close() and then setting it up so that the application exits only when the last window is closed, and not when the main window is closed?