Link to home
Start Free TrialLog in
Avatar of axnst2
axnst2Flag for United States of America

asked on

Activating MDIChild form from another MDIChild form

Hi Experts,

    I have and MDI UI and I need to be able to open an MDIChild form from another MDIChild form.  How do I accomplish that?

Thanks,
axnst2
Avatar of axnst2
axnst2
Flag of United States of America image

ASKER

I am doing this right now:

class MDIChild1 : Form
{
   private void cmdButton_Click(object sender, EventArgs e)
        {
            Form form = new Monitor(this.MdiParent);
            form.Show();
        }
}

public partial class MDIChild2 : Form
    {
        public Monitor(Form MDIParentForm)
        {
            InitializeComponent();
            this.MdiParent = MDIParentForm;
        }
    }
}

This works fine, but what I'd really like to do is to have a function in the MDIParent form that I could call to open a child form from any other child form!
Avatar of axnst2

ASKER

Sorry I it goes like this:

class MDIChild1 : Form
{
   private void cmdButton_Click(object sender, EventArgs e)
        {
            Form form = new MDIChild2(this.MdiParent);
            form.Show();
        }
}

public partial class MDIChild2 : Form
    {
        public MDIChild2 (Form MDIParentForm)
        {
            InitializeComponent();
            this.MdiParent = MDIParentForm;
        }
    }
}
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of axnst2

ASKER

So that it'll behave like the rest of my MDI forms.

Thanks, I tried what you suggested and it worked good.  Is this second MDIchild form disposed of when the user closes it, or do I have to free up the resources myself?
It is disposed of automatically when the user closes it (or when the application exits).  You don't need to do anything special to it...