0

I have an MDI form called "MDIParent1", MDI child form "MDIChild1" and I have a windows form called "FrmTest".

Now there is a button called "btnTest" in "MDIChild1" form and here is the click event.

Dim V As New FrmTest
    V.MdiParent = MDIParent1
    V.Show()

But It couldn't load the "frmTest" form. Is there any another way to do so? Thanks in advance.

Azhar Mansuri
  • 665
  • 1
  • 7
  • 22

1 Answers1

1

Try This :

    Dim V As New FrmTest
    V.MdiParent = Me.MdiParent
    V.Show()

The above assumes that MDIChild1.MdiParent is already set to MDIParent1

You could also do this :

    Dim V As New FrmTest
    V.MdiParent = Application.OpenForms("MDIParent1")
    V.Show()

To close other forms, iterate through MdiChildren collection :

    Dim MyMdiForm as Form = Application.OpenForms("MDIParent1")

    For Each Frm As Form In MyMdiForm.MdiChildren  

          If Frm IsNot V Then

                Frm.Close()

          End If

     Next
Abdusalam Ben Haj
  • 5,343
  • 5
  • 31
  • 45