Reputation: 39
I've been trying to solve a problem that occured on my program. All the forms I open from the menu refuse to center based in MDIParent
form. Since I'm using 2 panels to design a custom toolbar (containing the Close and Minimize buttons) and another panel regarding the menu.
Here is an image to explain my struggle on fixing my problem.
Things I've tried:
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
Upvotes: 2
Views: 1045
Reputation: 39
Answer by Hans Passant:
Since it would not work on the specific case of an MDI child window CenterScreen object should get the job done:
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
Upvotes: 1