Solved

Activating MDIChild form from another MDIChild form

Posted on 2006-06-22
5
251 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:axnst2
  • 3
  • 2
5 Comments
 

Author Comment

by:axnst2
ID: 16962418
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!
0
 

Author Comment

by:axnst2
ID: 16962430
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;
        }
    }
}
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 16962998
You could just do:

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

Why do you want the MdiParent to open the form?
0
 

Author Comment

by:axnst2
ID: 16963316
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?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 16963669
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...
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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