Question: I have a Main form.I want to launch another form from it and launch another from the launched form.I want to ensure that the Main form is not editable when sub forms are displayed so i use `showdialog()`

**Mainform>(Showdialog)>form1>(showDialog+dispose)>form2(dispose)>Mainform**

From Mainform i call form2.ShowDialog() then from form2 i use the following code to launch another form

```
this.visible=false;
form3.showdialog();
this.dispose();

```

But there are some problems in this.Is there a better way to achieve what im looking for?

```
edit:more description

```

I have a Main form,User clicks a Button on Mainform>Form1 is lauched>User clicks a Button in Form1>Form 2 is lauched(diposing/hiding form1) after form2 is closed Mainform should be brought to front and made editable,until then all other forms should be on top of Mainform and Mainform should be un-editable

Answer: 
The problem is that you have to specify the MainForm as the parent for (both) form2 and form3. When you use the overload of ShowDialog that has no parameters, WinForms uses the active form as the parent, so form3's parent becomes form2 automatically. You are then trying to close/dispose form2 causing form3 to become orphaned.

There are several options for getting the reference to MainForm, but the simplest is to use:

```
form2/3.ShowDialog(Application.OpenForms["MainForm"]);

```

Assuming that you have set the Name property on MainForm to "MainForm".
MainForm:

```
Form1 f = new Form1();
if (f.ShowDialog(this) == DialogResult.OK) {
    Form2 f2 = new Form2();
    f2.ShowDialog(this);
}

```

Form1 (button click which will open the form 2):

```
button1_click(object sender, EvengArgs e) {
    this.DialogResult = DialogResult.OK;
    Close();   
}

```