473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't open a Modal (showdialog) form

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?

Thanks
Mar 17 '10 #1

✓ answered by elmbrook

I have found a work around but it is not pretty.

What I have done is open the modal form from the MainForm. I have to call this method from my Child form. This works however, for every modal form in my application, I have to setup a new entry in my MainForm.

public void Open_Modal_Form(string formname)
{
switch (formname)
{

case "myModalForm":
myModalForm myform = new myModalForm ();
myform.ShowDialog(this);
break;
}
}

3 6592
ThatThatGuy
449 Expert 256MB
You cannot access a the parent form without closing the modal form...

it needs to be closed first...

although you should never use modal forms in mdi application,.... it should always be modaless...

Modal forms should only be for dialog forms
Mar 17 '10 #2
I think you may have mis-read the question.
I would like to open a modal form (dialog form) within my top level form.

They must fill out the information on my modal form first before they can continue.

Does that make sense?
Mar 17 '10 #3
I have found a work around but it is not pretty.

What I have done is open the modal form from the MainForm. I have to call this method from my Child form. This works however, for every modal form in my application, I have to setup a new entry in my MainForm.

public void Open_Modal_Form(string formname)
{
switch (formname)
{

case "myModalForm":
myModalForm myform = new myModalForm ();
myform.ShowDialog(this);
break;
}
}
Mar 18 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ivan Sammut | last post by:
Hi, I have 2 webform Webform1 & WebForm2 In Webform1 I have a button that when I click I want to first set a variable in WebForm2 & then open the Page. This is the code I have now which...
5
by: MrNobody | last post by:
I am using the no-arg ShowDialog() method hoping that the window would not be modal to any other window like the other ShowDialog(IWin32Window) method does, but when this opens it somehow becomes...
3
by: glenhong | last post by:
Im trying to display a popup window (similar to a context menu) and return a result from the selection. I want to do this as a modal popup ie. The code runs and displays the popup but pauses...
5
by: Tmajarov | last post by:
Haven't been able to find a clear answer to this... I am building an asp.net application and trying to enforce some work flow by displaying a form via the showmodaldialog method. I can get the...
4
by: Sender | last post by:
hello everyone i want to open form2 in modal form. how should i do that ? thanks in advance!
14
by: I_AM_DON_AND_YOU? | last post by:
Hello all: Yesterday I put this post regarding the query as to how to open a new form in "modal" style. I am calling the form in the following way: dim frm as form2() frm = new form2()...
3
by: Sarika | last post by:
I have some questions regarding Modal forms and would appreciate if someone could clarify my understanding. (a) I observed that the modal form's Form_Closing event is generated if I set the...
6
by: pamelafluente | last post by:
Hi guys I am puzzed (???) with a probably stupid problem (VB2003). I must be doing something dumb ... I want to open a owned form (must *not* be mdi child) over an Mdi Container, when the Mdi...
4
by: Johnny Jörgensen | last post by:
In my current project I've got some DataGridViews containing multiple hidden columns. For some reason 8 of the 10 grids I've got on my form has suddenly started showing 1 of the hidden columns...
2
by: =?Utf-8?B?UG9vamEgTmFyYW5n?= | last post by:
Hi, I have vb.net windows application where in i am opening a modal form- SubForm1 from MainForm1 (Not an MDIParent). When I switch over to another application such as IE Browser window and get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.