Force Center In Screen

D

Derek Hart

I am storing the height and width of a form so it opens the same each time
based on how the user resizes it. I would like to have the form centered
each time it opens, but the form uses the hard coded coordinates to
determine the center, and I set the height and width after (even though it
is in the constructor). After the height and width is set, is there a way to
center the form?
 
M

Miro

This should do the trick just replace the values.

Me.Left = (Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2
Me.Top = (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2
 

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