I’m launching a form from another form. I want the parent form to be disposed before showing the subform, so I use:
this.Dispose();
form.ShowDialog();
The form is displayed, is this the correct way to do it? The form from is launched by a call to ShowDialog() from the main form. I want these forms to be closed before the main form is editable.
EDIT:
This is the Basic Process
Mainform>(Showdialog)>form1>(dispose+showDialog)>form2(dispose)>Mainform
If you want to ensure the parent is not visible before the child is shown, AND you want the parent to Close:
ShowDialog()means, “display this form and return to me after it’s closed”. That is not what you described you want to happen.Based on your comment, it might make more sense to create and show form2 from your main form.
In the main form:
And in Form1 event where you originally spawned Form2