[RESOLVED] how to make form center during start up
How to make form center during start up depending on the screen resolution of the computer
My screen resolution is 1024 X 768 pixel .I have set the form start up as form center owner during design time. The form move to center of the screenduring start up.
But If I change the screen resolution to 1280 X 800 pixel, the form not appear on the center screen during start up but more to the right. How to make a form center in whatever resolution set on the computer screen
Re: how to make form center during start up
You can do this:
Code:
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) / 2, _
(Screen.Height - Me.Height) / 2
End Sub
Or change StartUpPosition = 2 (Center Screen) in the properties window.
Re: how to make form center during start up
You can just use one of the form properties, that is in the form properties window or you can do this by code. But I will show you how to do it by a single mouse click.
Get into the form properties window, then scroll down into the item, which is called StartUpPosition and then click on it, until you get what you are looking for.
Re: how to make form center during start up
@ThEiMp:
you need to read all replies before posting. ;)
Re: how to make form center during start up
Quote:
Originally Posted by RhinoBull
Or change StartUpPosition = 2 (Center Screen) in the properties window.
Use this.
Why write code if you don't have to? :D
Re: how to make form center during start up
Ehhh... I like controlling writable properties via code. :ehh:
Re: [RESOLVED] how to make form center during start up
One good reason to do this programatically is that if there are dual monitors, you can end up centering the form on the secondary monitor even though you wanted it on the primary. I find the center screen option is not reliable in this situation.