• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 663
  • Last Modified:

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

0
ITMikeK
Asked:
ITMikeK
  • 4
  • 2
1 Solution
 
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
 
ITMikeKAuthor Commented:
This is a very urgent issue.  Any help will be greatly appreciated!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Mike TomlinsonMiddle 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
 
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

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

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