How do I keep a MDI winform active?

I have a MDI menuControl frame that runs the enclosed code to control the opening and closing of forms.  My problem is that once the menu selection is clicked on. the correct form loads, but the only code behind that runs is the form constructor and then it returns to the parent MDI form.  It doesn't run the form Load() or anything else.  I need it to effectively "run" the selected form until the user selects another menu item or exits the app.  How can I do this?  Thanks!

 public void getForm(string node)
        {
            //  string node = e.Node.ToString();
            switch (node)
            {
                case "Time Entries":

                    frmTimeEntries objTimeEntries = new frmTimeEntries();
                    objTimeEntries.MdiParent = this;
                    this.panel2.Controls.Add(objTimeEntries);
                    objTimeEntries.Show();
                   

                    break;
                  default: 
                      break;
          }

        private void timeEntriesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            itemname = "Time Entries";
            closeform();
            getForm(itemname);
        }


        //This is the only code that gets executed before it returns back to the code above.

        public frmTimeEntries()
        {
            InitializeComponent();
        }

Open in new window

ITMikeKAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anarki_jimbelSenior DeveloperCommented:
I tried but I haven't your problem.
But it crashes on the

              this.panel2.Controls.Add(objTimeEntries);

line. You do not need to add your MDI form to controls...

http://www.codeproject.com/Articles/3553/Introduction-to-MDI-Forms-with-C
0
ITMikeKAuthor Commented:
But once I open the child form, there are a bunch of controls (like a BindingNavigator), that doesn't get a chance to populate.  There are are also several drop downs that need to populate.  Should all of this be done in the child form constructor?  From what I can tell, the control focus returns to the parent form once the child constructor completes.  Make sense?
0
ITMikeKAuthor Commented:
This is a very urgent issue.  Any help will be greatly appreciated!
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
The Load() event fired fine for me (in addition to the Constructor) so you've got something setup incorrectly.

Are you sure you have the Load() event wired up correctly?...double check please, don't just say "yes".  =)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITMikeKAuthor Commented:
Idle_Mind,

    You were correct!  My event handler for the Load was not correct (what happens when you cut and paste while fatigued!).  Thank you.  Look for my next question title "How do I keep the menu bar in focus at all times".
0
ITMikeKAuthor Commented:
Idle_Mind,

    You were correct!  My event handler for the Load was not correct (what happens when you cut and paste while fatigued!).  Thank you.  Look for my next question title "How do I keep the menu bar in focus at all times".
0
anarki_jimbelSenior DeveloperCommented:
Just in case - was I correct about the following line? :)

       
     this.panel2.Controls.Add(objTimeEntries);

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.