Home All Groups Group Topic Archive Search About

MDI Parent/Child forms

Author
15 Mar 2006 2:59 PM
Linda U
This is what I have - Form1 is an MDI Container, form2 is an MDI Child
of form1, Form3 is a model form.  What I want to be able to do is
activte form2 as a child of form1 from form3.  The problem is that
form3 is not a child of form1 so I have no way of setting the mdiParent
property from form2.  Does anyone know how to set the parent property
in this instance?
The other thing that would work is if you could have a model child
form, but .net doesn't seem to let you do this, or am I missing
something?

Thanks for your help,
Linda

Author
15 Mar 2006 3:16 PM
Kerry Moorman
Linda,

You are correct that an mdi child form cannot be shown modally.

Here is one way to accomplish what you need:

The form to be shown modally needs a reference to the mdi container. So in
form3 add a property to reference the container:

     Public mdiContainer As Form1

On the mdi container form, write code to show form3 modally:

        Dim f As New Form3
        f.mdiContainer = Me

        f.ShowDialog()

On form3, write code to show form2 as an mdi child form:

        Dim f As New Form2
        f.MdiParent = Me.mdiContainer
        f.Show()

        Me.Close()


Kerry Moorman


Show quoteHide quote
"Linda U" wrote:

> This is what I have - Form1 is an MDI Container, form2 is an MDI Child
> of form1, Form3 is a model form.  What I want to be able to do is
> activte form2 as a child of form1 from form3.  The problem is that
> form3 is not a child of form1 so I have no way of setting the mdiParent
> property from form2.  Does anyone know how to set the parent property
> in this instance?
> The other thing that would work is if you could have a model child
> form, but .net doesn't seem to let you do this, or am I missing
> something?
>
> Thanks for your help,
> Linda
>
>
Author
15 Mar 2006 7:13 PM
Linda U
Thank you!  This worked great.

Linda