Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

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
0
ITMikeK
Asked:
ITMikeK
  • 2
  • 2
1 Solution
 
ITMikeKAuthor Commented:
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"a panel control below it that displays the current child form"

It appears that you have AutoScroll() for the entire FORM set to True.

Here is what I'd try first:
(1) Turn OFF AutoScroll() for the FORM.
(2) Make sure whatever is holding your "menu" has Dock() set to "Top".
(3) Change your "child form" panel Dock() to "Fill".
(4) Turn ON AutoScroll() for the "child form" PANEL.
(5) Make sure your child forms default to "maximized" or Dock() "Fill" when they open.
0
 
ITMikeKAuthor Commented:
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!
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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:
                    frmTimeEntries objTimeEntries = new frmTimeEntries();
                    objTimeEntries.MdiParent = this;
                    this.panel2.Controls.Add(objTimeEntries);

Open in new window


...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);

Open in new window


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).
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now