当我想要打开一个新表单时,如何关闭MDI Chid表单。
通过这种方式我打开了他们两个但我想在打开新的时关闭前一个。
Private Sub DostupniToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DostupniToolStripMenuItem.Click
Dim frm As New FrmDostupniZaposlenici
frm.MdiParent = Me
frm.Show()
frm.WindowState = FormWindowState.Maximized
End Sub
Private Sub DodajToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DodajToolStripMenuItem.Click
Dim frm As New frmDodajZaposlenika
frm.MdiParent = Me
frm.Show()
frm.WindowState = FormWindowState.Maximized
End Sub
我有大约10个mdi儿童表格。
编辑:
新代码。如何防止在表单上打开表单。示例我想在新表单打开时关闭所有其他mdi表单。 这样,如果我点击工具栏中的4个按钮,我就打开了4个表格。我不希望这样。如果我单击按钮3,我想关闭上一个表单并加载form3。
Private Sub DostupniToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DostupniToolStripMenuItem.Click
FrmDostupniZaposlenici.MdiParent = Me
FrmDostupniZaposlenici.Show()
FrmDostupniZaposlenici.WindowState = FormWindowState.Maximized
End Sub
Private Sub DodajToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DodajToolStripMenuItem.Click
frmDodajZaposlenika.MdiParent = Me
frmDodajZaposlenika.Show()
frmDodajZaposlenika.WindowState = FormWindowState.Maximized
End Sub
Private Sub IzmjeniToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IzmjeniToolStripMenuItem.Click
frmIzmjenaZaposlenika.MdiParent = Me
frmIzmjenaZaposlenika.Show()
frmIzmjenaZaposlenika.WindowState = FormWindowState.Maximized
End Sub
Private Sub ObrisiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ObrisiToolStripMenuItem.Click
frmObrisiZaposlenika.MdiParent = Me
frmObrisiZaposlenika.Show()
frmObrisiZaposlenika.WindowState = FormWindowState.Maximized
End Sub
答案 0 :(得分:1)
只需遍历所有打开的MDI子窗体并关闭它们......
For Each f As Form In Me.MdiChildren
f.Close()
Next
答案 1 :(得分:0)
要首先关闭打开的子窗体,请在声明子窗体后立即在菜单项的click事件中输入以下代码。
ActiveMdiChild.Close()