Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making a project that consists of storing employee records through MDI forms..
Now after selecting Add New Button, I want the second child form to be active and the first (parent form)form to be disabled for the time being.

I've tried to use the showdialog() method, but due to its MDI form, its shows an error stating "The form being shown is not a top-level window."
If this is not possible in mdi conditions,
what is it that I can do to execute the same.
Posted
Comments
Maciej Los 16-Jan-16 16:14pm    
Why to use MDI? Forget about it!

1 solution

The error message is right: and MDI child form cannot be modal - which is what the ShowDialog method is there to do.
If you want the main (MDI parent) window to "disappear" while the new window is visible, then it can't be an MDI child window, it must be a regular "top level" window - and then you just do this:
VB.NET
Dim mnf As New MyNewForm()
Hide()
Dim result As DialogResult = mnf.ShowDialog()
Show()
 
Share this answer
 
Comments
Dishi_Gupta 16-Jan-16 3:34am    
Sir is it not possible anyway that this happens alongwith the MDI property? Because the Mdi property condition is necessary for the whole code/project..
OriginalGriff 16-Jan-16 4:17am    
It will work fine, provided you don't try to make the new form and MDI child: The code I gave you will work if you don't change it.
If you are trying to add another MDI child instead, just set it's MDIParent to the MDI main form, and use the Show method instead of ShowDialog.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900