MDI child forms: how can one open another form?

  • Thread starter Thread starter Juan Dent
  • Start date Start date
J

Juan Dent

Hi,

In an MDI Windows forms architecture, I have several child forms which I
need to be able to open fellow child forms. How is this done?
 
Dear Juan,

Based on your description, you have several child forms in a MDI container
which you want to be able to open fellow child forms.

I am not exactly sure about what you mean. When you mention "fellow child
forms", do you mean you want to open new forms from the child form, and
the new forms also be child forms of the MDI container?

If this is the case, we can call the Form.Show() method in the child form
to open the new forms, and set MdiParent property of the new form to be
the same as the child form's MdiParent property.

For example, we have a child form named "Form1" in the MDI container. On
the Form1, there is a button, click on which we want to open a new form
named "Form2", then we can do something like this in the click event
handler of the button:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.MdiParent = this.MdiParent;
f2.Show();
}
}

For more information about the MDI applications, you can read these
documents:

Working with MDI Applications and Creating Menus
http://msdn.microsoft.com/en-us/library/ms973874.aspx

Form.MdiParent Property
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.mdiparent.
aspx

Sincerely,
Zhi-Xin Ye
Microsoft Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top