• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

How to open a form centered?

How do I make sure a form opens in the center of my screen?  Thanks
0
InvisibleMan
Asked:
InvisibleMan
1 Solution
 
vinnyd79Commented:
Set the forms StartUpPosition to  'CenterScreen'
0
 
ChenChenCommented:
Two ways:
1. add these two lines in the Sub form_load:
    me.left=(screen.width-me.width)/2
    me.top=(screen.height-me.height)/2

2. set StartUpPosition property to 'CentreScreen'

0
 
sanjaykattimaniCommented:
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]
0
 
vbPhilCommented:
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.

0
 
InvisibleManAuthor Commented:
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now