Solved

Activating MDIChild form from another MDIChild form

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
send mail from app.net 8 28
asp.net bundle 8 36
Data Saving(2) 2 25
How to LOAD up a .NET Framework website with data? 2 12
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now