Having a main form with a button with which I access the second form, how can I return to the main form when closing the second using the x button?
Form1:
private void buttonEnterAdmin_Click(object sender, EventArgs e)
{
this.Hide();
Login login = new Login();
login.Show();
}
Form2:
private void Login_FormClosed(object sender, FormClosedEventArgs e)
{
Main main = new Main();
main.Show();
}
You can use the event FormClosed Subscribe to the event and you can open it the moment you close it
a small example
Documentation source: FormClosed event
If you need the event to fire before the form is Closed Use the Form.FormClosing event Form.FormClosing event
Since the event of FormClosing I understand is fired before FormClosed