2

我有主窗体,它是 MDI 父窗体。

在里面我打开了第二个(相同的解决方案,不同的项目)表单,如下所示:

Dim f As New mynevproj.frm_list
With f
  .MdiParent = Me
  .Show()
End With

在这些新表单 (frm_list) 中,我在少数情况下会打开另一个新表单:

Dim fa As New frm_art1
With fa
  .StartPosition = FormStartPosition.Manual
  .Location = New Point(Me.Location.X + 20 + (inst * 20), Me.Location.Y))
   AddHandler .aClosed, AddressOf frm_artikl_Closed
  .Show()
End With

发生什么了?

当我打开几个 frm_art1 实例然后关闭 frm_list 时,我希望所有 frm_art1 都将关闭以关闭 frm_list。

但这不会发生。

每次我单击 (X) 关闭 frm_list 时,frm_art1 的一个实例就会关闭,最后当所有 frm_art1 都关闭时,frm_frm_list 就会关闭。

当我关闭 frm_list 时,如何关闭通过 frm_list 打开的所有表单。

这在非 MDI 环境中效果很好。

现在我在frm_list的form_closure中另外尝试了这个:

For Each frm As Form In My.Application.OpenForms
  If frm.Name = "frm_art1" Then
    frm.Close()
  End If
Next

这也行不通!

4

1 回答 1

0

尝试使 frm_list 成为其他表单的所有者:

Dim fa As New frm_art1
With fa
  .StartPosition = FormStartPosition.Manual
  .Location = New Point(Me.Location.X + 20 + (inst * 20), Me.Location.Y))
  AddHandler .aClosed, AddressOf frm_artikl_Closed
  .Owner = Me
  .Show()
End With
于 2012-09-26T17:48:50.443 回答