I have a small application with multiple forms (Form1..Form5).
Form1 is the main one.
Every time I go from Form1 to another Form I do it with the command (Foe ex. from Form1 to Form2):
private void button1_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
form.Show();
form.FormClosing += (obj, args) => { this.Close(); };
this.Hide();
}
I would like to know how I can return to Form1 when the x in the top right is pressed.
I am trying with the code:
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
Form1 form = new Form1();
form.Show();
}
But don’t work.
can someone help me?