how to place child form in the middle of its parent form

osamaakhattab

New member
Joined
Feb 8, 2006
Messages
4
Programming Experience
1-3
hi Folks:
I am trying to locate the child filed in the middle of it parents when the parent form load, but unfortunatily it keep appears in the left corner of the parent form.

this is my code :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True

Dim x As New Form2()
x.MdiParent = Me
x.StartPosition = FormStartPosition.CenterParent
x.Show()
 
That seems not to work for MDI child forms. I thought that it would be CenterScreen but that doesn't work either. You can do it manually though:
VB.NET:
        Dim f As New Form

        f.StartPosition = FormStartPosition.Manual
        f.Location = New Point((Me.ClientSize.Width - f.Width) \ 2, (Me.ClientSize.Height - f.Height) \ 2)
        f.MdiParent = Me
        f.Show()
 
Back
Top