/*When we close the form call a function from one of the forms and then close.*/ private void Init_FormClosing(object sender, FormClosingEventArgs e) { /*Seeing what the form is.*/ try { Form1 form1 = (Form1)parentForm; form1.SettingsClosed(this); } catch (Exception error) { Console.WriteLine(error.ToString()); } /*Seeing what the form is.*/ try { Compare compare = (Compare)parentForm; compare.SettingsClosed(this); } catch (Exception error) { Console.WriteLine(error.ToString()); } /*Seeing what the form is.*/ try { Overview overview = (Overview)parentForm; overview.SettingsClosed(this); } catch (Exception error) { Console.WriteLine(error.ToString()); } }
private void OverviewButton_Click(object sender, EventArgs e) { this.Hide(); Overview overview = new Overview(); overview.Closed += (s, args) => this.Close(); overview.Show(); }