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?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
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
 
anarki_jimbelCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
ITMikeKAuthor Commented:
This is a very urgent issue.  Any help will be greatly appreciated!
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
 
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_jimbelCommented:
Just in case - was I correct about the following line? :)

       
     this.panel2.Controls.Add(objTimeEntries);

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.