Solved

Activating MDIChild form from another MDIChild form

Posted on 2006-06-22
5
255 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

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.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

617 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