InvisibleMan
asked on
How to open a form centered?
How do I make sure a form opens in the center of my screen? Thanks
Set the forms StartUpPosition to 'CenterScreen'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Above 2 ways you can centre the screen,
Make sure that once you set the startupPosition property, you do not drag the window or change the position [that resets the startupPosition property]
Make sure that once you set the startupPosition property, you do not drag the window or change the position [that resets the startupPosition property]
I agree with the above, but I also like to keep the form invisible, until it is sized and/or centered.
Set Visible = False
in the Form_Load() event
'Size it first if necessary...
Me.Left = (Screen.Width - Me.width) / 2
Me.Top = (Screen.Height - Me.height) / 2
Doevents
Me.Show
This makes sure all of the moving around is finished before the user sees it.
Set Visible = False
in the Form_Load() event
'Size it first if necessary...
Me.Left = (Screen.Width - Me.width) / 2
Me.Top = (Screen.Height - Me.height) / 2
Doevents
Me.Show
This makes sure all of the moving around is finished before the user sees it.
ASKER
Can someone give me a function or sub I could call to make sure they open in center view? Thanks. This way I can pass in a form.