command something in one form when closing another form wfp c# code example
Example 1: open a new form with a button and close the last one
this.Hide();
var form2 = new Form2();
form2.Closed += (s, args) => this.Close();
form2.Show();
Example 2: c# open a new form and close current
{
this.Hide();
Form1 f1 = new Form1();
f1.ShowDialog();
this.Close();
}