在MDI Parent窗体中打开窗体时如何居中?

时间:2017-04-18 15:48:29

标签: vb.net

我一直在尝试解决程序中出现的问题。我从菜单中打开的所有表单都拒绝以MDIParent形式居中。因为我使用2个面板来设计自定义工具栏(包含关闭和最小化按钮)和另一个关于菜单的面板。

这是一张解释我在解决问题方面的努力的图片。

Image regarding my problem

我尝试过的事情:

Private Sub RegistarDevoluçãoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RegistarProjetoToolStripMenuItem.Click
    Dim janela As New frmRegProjeto
    janela.MdiParent = Me
    janela.StartPosition = FormStartPosition.CenterParent
    janela.Show()
End Sub

1 个答案:

答案 0 :(得分:1)

Hans Passant的回答:

由于它无法在MDI子窗口的特定情况下工作,因此CenterScreen对象应该完成工作:

       Private Sub RegistarDevoluçãoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RegistarProjetoToolStripMenuItem.Click
         Dim janela As New frmRegProjeto
         janela.MdiParent = Me
         janela.StartPosition = FormStartPosition.CenterScreen
         janela.Show()
       End Sub