Вопрос

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.

Это было полезно?

Решение

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top