Solved

Activating MDIChild form from another MDIChild form

Posted on 2006-06-22
5
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 86

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 86

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

738 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