How do I keep the Menubar visible while changing forms in an MDI winform?

Posted on 2012-09-21
Last Modified: 2012-09-21
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?
Question by:ITMikeK

    Author Comment

    LVL 85

    Accepted Solution

    "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.

    Author Closing Comment

    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!
    LVL 85

    Expert Comment

    by:Mike Tomlinson

    *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;

    Open in new window 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;

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now