Question

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.

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top