-
Jan 16th, 2010, 10:14 PM
#1
Thread Starter
Lively Member
[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.
-
Jan 16th, 2010, 10:25 PM
#2
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
-
Jan 16th, 2010, 11:01 PM
#3
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.
-
Jan 17th, 2010, 01:48 AM
#4
New Member
Re: About position and size
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
-
Jan 17th, 2010, 02:20 AM
#5
Re: About position and size
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.
-
Jan 17th, 2010, 03:30 AM
#6
New Member
Re: About position and size
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!
-
Jan 17th, 2010, 02:02 PM
#7
Thread Starter
Lively Member
Re: [RESOLVED] About position and size
Thank you all for these lovely answers!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|