I am unable to open a child form as a modal form.
Here is my scenario
I have a MainForm which is a toplevel form.
Inside the MainForm I have a Toolbar Form which is a child.
From the Toolbar Form I call another child form.
From that child form I need to call myModalForm.
I have tried:
myModalForm myform = new myModalForm ();
myform.TopLevel = true;
myform.MdiParent = this.mdiparent;
myform.ShowDialog();
Result: 'Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling showDialog.'
So I thought I would close the existing form first and then call the modal form
this.close();
myModalForm myform = new myModalForm ();
myform.TopLevel = true;
myform.ShowDialog();
Result: IT works...however, it is not inside the top level form.
So I thought I would open an instance of the MainForm and set that as the MDIParent
this.Close(); //Close Current Form
MainForm topform = new MainForm(); // Create new instance of MainForm
myModalForm myform = new myModalForm ();
topform.TopLevel = true;
myform.MdiParent = topform;
myform.ShowDialog();
Result: 'Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling showDialog.'
Can anyone help me get a modal form within my toplevel MainForm?
I thought this should be simple...Am I missing something?
Thanks