ITMikeK
asked on
How do I keep the Menubar visible while changing forms in an MDI winform?
I have a MDI Winform with a menu bar control on top and a panel control below it that displays the current child form. When I start the application and/or change forms, the menu bar moves out of sight. It appears as when its done painting the form, the focus is on the bottom right of the panel. How would I fix this?
Pic1.png
Pic1.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Still don't have it exactly the way I want it, but you did point me in the right direction, just have to mess with it more. Thanks!
Cool.
*Note, though, that you are not really using "MdiForms" here...and this can cause great confusion and heartache in further questions as people make suggestions based on that premise since the normal MDI model doesn't fit exactly what you're doing...
I would simply say that you have "child forms" displayed inside a Panel.
What's really happening with your code (from your PAQ) here:
...is that setting ".MdiParent" causes the TopLevel() property for you child form to be set to False. This is the pre-requisite that allows the form to be added to the Panel (panel2) in the third line. It could also be achieved like this intead:
Note the different second line. With this second approach, you do NOT need to set IsMdiContainer() to True for your Form (since you are not really using it as an MDI container).
*Note, though, that you are not really using "MdiForms" here...and this can cause great confusion and heartache in further questions as people make suggestions based on that premise since the normal MDI model doesn't fit exactly what you're doing...
I would simply say that you have "child forms" displayed inside a Panel.
What's really happening with your code (from your PAQ) here:
frmTimeEntries objTimeEntries = new frmTimeEntries();
objTimeEntries.MdiParent = this;
this.panel2.Controls.Add(objTimeEntries);
...is that setting ".MdiParent" causes the TopLevel() property for you child form to be set to False. This is the pre-requisite that allows the form to be added to the Panel (panel2) in the third line. It could also be achieved like this intead:
frmTimeEntries objTimeEntries = new frmTimeEntries();
objTimeEntries.TopLevel = false;
this.panel2.Controls.Add(objTimeEntries);
Note the different second line. With this second approach, you do NOT need to set IsMdiContainer() to True for your Form (since you are not really using it as an MDI container).
ASKER
Pic2.png
pic3.png