Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Greetings,

I have been to an illogical programming case:

I have created MDIParent form "Form1" and then add another form "Form2" to the project then set "Form1" as the parent form of "Form2" on the "Form1" load event through the following code:


VB
Dim ChildForm As New Form2
ChildForm.MdiParent = Me  'Which is Form1
ChildForm.Show()



Now I added a panel "Panel1" to the parent form "Form1" and set its Dock property to Full in order to cover all the "Form1".

What is weird is that at the load event of "Form1", "Form2" should appear, but what happened was that it didn`t appear and it looked like it is under the panel "Panel1".

So what is the method or syntax in Vb.Net that makes "Form2" which is the MDIChild of "Form1" to appear on top of all controls that are added to the parent form "Form1" and not under them?

Please advise...

Thanks in advance....
Posted
Comments
Sergey Alexandrovich Kryukov 8-Feb-12 11:38am    
Why are you trying to torture yourself with this?
--SA

The MdiChild form IS showing. The problem is you covered up the entire MdiClient control on the MdiParent form with a Panel Docked to the entire form.

Remove the Panel control. I have no idea why you put it there.

The MdiClient control that is automatically put on a MdiParent form is already Docked Full in the form. You would have to search the Controls collection of Form1 to find the MdiClient control, then manipulate it to whatever condition you need, whatever that is. You could even call it's BringToFront method, but then that would cover up all the controls you dropped on Form1, including your panel, so what's the point??
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Feb-12 11:37am    
My 5, but only for this post as a convincing evidence that it's the best to get rid of MDI, it makes no sense, really.

Please see my answer.
--SA
From your question and the answer by Dave I can see that you are abusing MDI. But this is not your fault, this is a fault of MDI designers: this is MDI that abuses the reasonable sense of the UI. That's why MDI is highly discouraged, even by Microsoft. Microsoft tries hard to get rid of it. MDI is not reproduced in WPF, for example.

The advice is simple: don't use MDI, don't make your life harder and don't chase off your customer with all that ugliness. There are much better and easier ways.

Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to Create MDI Parent Window in WPF?[^],
How to set child forms maximized, last childform minimized[^].

—SA
 
Share this answer
 
Comments
Dave Kreskowiak 8-Feb-12 16:05pm    
How is it the fault of the MDI designers if a bunch of newbies abuse it and don't know how to use it how it was meant to be used??

How is it SnapOn Tools fault is someone abuses using a socket wrench??
Greetings,

Thanks guys for your replies.

I just want to clarify my point behind the addition of a panel to the MDIParent form...

I need to have some controls on the MDIParent form (i.e. buttons, pictureboxes), and I also need to load a MDiChild forms (login form, client form) while the user is navigating through the application. So when a user clicks on a button, a child form should be opened on the top level (top most) and not behind those buttons or pictureboxes.

So I added the panel and add the controls to it and so I can make it visible or no depends on the loading of any childform.....

But I think that this design is not pretty mature, and so I`m seeking for a better solution or workaround since what I really need is to have the child form loaded and the controls in the mdiparent form still visible but behind the child form and not vice versa...

Please execuse me if my english is not very understandable...

Please advise...
 
Share this answer
 

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