StartPosition=CenterParent doesn't seem to work

  • Thread starter Phillip Ross Taylor
  • Start date
P

Phillip Ross Taylor

I have configured a few of the windows I am working on to have the
form value "Start Position" to be "CenterParent" but some of them
don't.

Does Center Parent only work when the dialog is modal? I'm not writing
an MDI application so I other posts I've read just don't seem very
relevent.

Do I have to explicitly set the parent??? What if I don't know it is?

Anyone?

Thanks in advance, Phill
 
K

Kevin S Gallagher

Interesting, I just tried it using .Show and it didn't center then
..ShowDialog and it did. Both times FormStartPosition.CenterParent
 
R

Robert Schneider

Phillip Ross Taylor said:
I have configured a few of the windows I am working on to have the
form value "Start Position" to be "CenterParent" but some of them
don't.

Does Center Parent only work when the dialog is modal? I'm not writing
an MDI application so I other posts I've read just don't seem very
relevent.

Do I have to explicitly set the parent??? What if I don't know it is?

Hm. The following code works fine for me:

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click

Dim f As New Form()
f.Owner = Me
f.StartPosition = FormStartPosition.CenterScreen
f.ShowInTaskbar = False
f.Show()

End Sub

With parent you mean owner, I guess. The MSDN help says about the Owner
property of a form:

"When a form is owned by another form, it is minimized and closed with the
owner form. For example, if Form2 is owned by form Form1, if Form1 is closed
or minimized, Form2 is also closed or minimized. Owned forms are also never
displayed behind their owner form. You can use owned forms for windows such
as find and replace windows, which should not disappear when the owner form
is selected. To determine the forms that are owned by a parent form, use the
OwnedForms property."

Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top