Force Center In Screen

  • Thread starter Thread starter Derek Hart
  • Start date Start date
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?
 
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
 
Back
Top