I want to open new form f2 and close current form f1 but when i tried this.close both forms close and this.hide just hide the form.
Form2 f2 = new Form2();
f2.ShowDialog();
this.Close(); //this.Hide();
I want to open new form f2 and close current form f1 but when i tried this.close both forms close and this.hide just hide the form.
Form2 f2 = new Form2();
f2.ShowDialog();
this.Close(); //this.Hide();
Try Show method, Showdialog will act like f2 is the children of f1 and close both form.
Form2 f2 = new Form2();
f2.Show();
this.Close();
Close() on the main window normally terminates the program.
ShowDialog() shows the Form as modal dialog. The calling function will wait until the dialog is closed.
If you display a dialog, you should not try to close the calling window. If you need to display just another window, use Form.Show()