Check this approach:
Private Sub FrmSearch_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Left = Parent.ClientSize.Width - Me.Width
Me.Top = Parent.ClientSize.Height - Me.Height
End Sub
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
After following the advice from so many posts about correctly positioning a form in the bottom right corner of the screen, I can’t believe it’s not working correctly for me.
I display my main form, which is MDI. In its Shown routine, it shows the frmSearch form:
Private Sub FrmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
Dim Search As New frmSearch ' Create a Search form
Search.MdiParent = Me ' Tell it who's the boss: frmMain
Search.Show()
End Sub
In the frmSearch Load routine, I set the location of the frmSearch form to what -should- properly position it in the bottom right corner of my screen:
Private Sub FrmSearch_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim scr As Screen = Screen.FromPoint(Cursor.Position)
Me.Location = New Point(scr.Bounds.Right - Me.Width, scr.WorkingArea.Bottom - Me.Height)
End Sub
The screen shows up basically in the bottom right corner, but there are horizontal and vertical slide bars:
Even stranger, when I then slide the right bar down, then slide the bottom bar to the right, the slidebars disappear, leaving the form right-justified, but higher than the bottom:
If I run it again and reverse the order, sliding bottom first, then the right bar, the form ends up bottom-justified and away from the right side.
I’m stumped. Anybody have a suggestion?
Using Visual Studio 2022 and VB.Net on Windows 11.
Check this approach:
Private Sub FrmSearch_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Left = Parent.ClientSize.Width - Me.Width
Me.Top = Parent.ClientSize.Height - Me.Height
End Sub