Reputation: 10192
How can I position a form at the bottom right corner of the screen when the form loads? I'm using Visual Basic 2010 Express.
Thanks
EDIT: I did this and it seems to work great.
Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width - 400
y = Screen.PrimaryScreen.WorkingArea.Height - 270
Me.Location = New Point(x, y)
Upvotes: 9
Views: 107009
Reputation: 2997
Try this solution. It working for me at VS 2019
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Me.Top = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - Me.Height
Me.Left = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - Me.Width
MyBase.OnLoad(e)
End Sub
goodluck
Upvotes: 0
Reputation: 1117
you can try like
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.StartPosition = FormStartPosition.Manual
Me.Location = Screen.GetWorkingArea(Me).Location
End Sub
Upvotes: 1
Reputation: 13633
If you want to position the form on the screen cursor is on, use:
' Get Active Screen Cursor is On, rather than assuming user on PrimaryScreen
Dim scr As Screen = Screen.FromPoint(Cursor.Position)
Me.Location = New Point(scr.WorkingArea.Right - Me.Width, scr.WorkingArea.Bottom - Me.Height)
Upvotes: 1
Reputation: 1195
Center Screen:
Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2)
Right Bottom Corner Screen:
Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)
Upvotes: 4
Reputation: 4945
simply this does the trick for me: poitions just above/left of taskar s the case may be.
Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
y = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Me.Location = New Point(x, y)
Upvotes: 3
Reputation: 89
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Visible = True
Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width
y = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Do Until x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
x = x - 1
Me.Location = New Point(x, y)
Loop
End Sub
Upvotes: 8
Reputation: 6894
You can loop through the child forms and do some calculations based on the top and left properties (might want to combine those calcs with Width and Height properties depending on what your requirement is for "bottom left")
HTH, Mark
Upvotes: 0
Reputation: 166606
You need to change the Form.StartPosition to Manual and change the Location property of the form
eg how to set form startup location/position manually?
or
VB.net - Form Start Position Upper Left
using Form.StartPosition Property and Form.Location Property
Upvotes: 6