private void openPreferencesModally_Click(object sender, EventArgs e) { PreferencesDialog dlg = new PreferencesDialog(); dlg.hideApplyButton(); dlg.ShowDialog(); dlg.Dispose(); }
private void openPreferencesModelessly_Click(object sender, EventArgs e) { bool formOpen = false; foreach (Form form in Application.OpenForms) if (form is PreferencesDialog) formOpen = true; if (!formOpen) { PreferencesDialog dlg = new PreferencesDialog(); dlg.Show(this); } else MessageBox.Show("Error: Cannot open. A Preferences dialog is already open."); }