private void DisplayButton_OpenRegistrationForm(object sender, MouseEventArgs e) { bool error = true; try { ClearTextFields(); DisplayForm displayForRef = this; RegistrationForm registrationForm = new RegistrationForm(ref displayForRef); registrationForm.ShowDialog(); error = false; } catch (Exception expMsg) { MessageBox.Show("application run into an error" + expMsg.Message); } finally { if (error) { this.Close(); } } }
/// <summary> /// constructor: to invoke InitializerComponent funciton /// </summary> public RegistrationForm(ref DisplayForm displayForm) { InitializeComponent(); displayFromRef = displayForm; }