[RESOLVED] About position and size
hey guys, I'm using VB2008 and I was wondering this:
I make my program start as "maximized" and place 1 button on the left upper corner and another button in the lower right corner, when I launch the program the buttons just places themself as in the design mode in VB, what can I do to make those buttons get in those corner? is it possible to put them in % ?
This is because I want my program to work with every screen resolution, Thanks :)
oh and by the way, I didn't know what this kind of problem where So therefor I couldn't search for it in the forums.
Re: About position and size
Possibly something along these lines:
Code:
Me.WindowState = FormWindowState.Maximized
Me.Button1.Left = My.Computer.Screen.WorkingArea.Size.Width - Me.Button1.Width
Re: About position and size
You don't need any code at all. Simply position your Buttons where you want relative to the form edges, then set their Anchor properties to those edges. The Button in the top-left corner should have its Anchor set to (Top, Left), which is the default. The other should be set to (Bottom, Right), because you want the Button to remain in a fixed position relative to the bottom-right corner.
Re: About position and size
Quote:
Originally Posted by
Bruce Fox
Possibly something along these lines:
Code:
Me.WindowState = FormWindowState.Maximized
Me.Button1.Left = My.Computer.Screen.WorkingArea.Size.Width - Me.Button1.Width
Hi Bruce
So to centre a form at runtime would one use something like the following?
Me.Top= (My.Computer.Screen.WorkingArea.Size.Height - Me.Height) / 2
Me.Left = (My.Computer.Screen.WorkingArea.Size.Width - Me.Width) / 2
Re: About position and size
Quote:
Originally Posted by
ddclondon
Hi Bruce
So to centre a form at runtime would one use something like the following?
Me.Top= (My.Computer.Screen.WorkingArea.Size.Height - Me.Height) / 2
Me.Left = (My.Computer.Screen.WorkingArea.Size.Width - Me.Width) / 2
Assuming you mean when you open the form in the first place, to centre a form you would set its StartPosition property to CenterScreen.
Re: About position and size
Quote:
Originally Posted by
jmcilhinney
Assuming you mean when you open the form in the first place, to centre a form you would set its StartPosition property to CenterScreen.
An elegant solution and you're a star!
Thank you!
Re: [RESOLVED] About position and size
Thank you all for these lovely answers!