MDI Parent/Child forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Linda U

    #1

    MDI Parent/Child forms

    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

  • Kerry Moorman

    #2
    RE: MDI Parent/Child forms

    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


    "Linda U" wrote:
    [color=blue]
    > 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
    >
    >[/color]

    Comment

    • Linda U

      #3
      Re: MDI Parent/Child forms

      Thank you! This worked great.

      Linda

      Comment

      Working...