ayha1999
asked on
Modal window
Hi,
I have an mdi form and a standard on C# 2010 windows application. How can I load the standard form as modal window while loading the the mdi form. i.e. mdi form on the background and the standard form as modal window. if user click the close button on the modal window, the application should exit. If user cick a button on the modal window, the modal window should close and the mdi form should be active.
Please help.
ayha
I have an mdi form and a standard on C# 2010 windows application. How can I load the standard form as modal window while loading the the mdi form. i.e. mdi form on the background and the standard form as modal window. if user click the close button on the modal window, the application should exit. If user cick a button on the modal window, the modal window should close and the mdi form should be active.
Please help.
ayha
ASKER
I am not able to load the mdi form in the background. Only when the child form close, the mdi form comes up.
Program.cs
static void Main ( )
{
Application.EnableVisualSt yles ();
Application.SetCompatibleT extRenderi ngDefault (false);
Application.Run (new mdi ());
}
MDI form
private void mdi_Load (object sender, EventArgs e)
{
login f = new login ();
f.ShowDialog ();
}
Please check if I need to change something.
thanks
Program.cs
static void Main ( )
{
Application.EnableVisualSt
Application.SetCompatibleT
Application.Run (new mdi ());
}
MDI form
private void mdi_Load (object sender, EventArgs e)
{
login f = new login ();
f.ShowDialog ();
}
Please check if I need to change something.
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the mdi form is loading now but the login form(child) can be moved out of the parent window. How can I prevent it?
when I tried
login.MDIParent = this;
getting error. For closing the application when clicking close button of the login window, it doesn't close.
thanks
ayha
when I tried
login.MDIParent = this;
getting error. For closing the application when clicking close button of the login window, it doesn't close.
thanks
ayha
You don't specify MDI parent for modal form. Just remove this line.
ASKER
Even without this line, the child window can be moved out of the parent window. is there any other I set the login form as child .
thanks
thanks
Why do you want to set login form as child window? As I understand, It should be used only once, during application startup. The point of having child forms in MDI is to be able to interact with them simultaneously, or to switch between them. That's not the case with login, is it?
ASKER
Yes. Actually not for login I want it, but for other forms in the application.
OK then. Just don't set MDIParent for modal forms
ASKER
Thanks
To display a modal form, use this:
Open in new window
To handle close event:
Open in new window