user774411 user774411 - 5 months ago 42
Vb.net Question

How to set winform start position at top right?

How to set

winform
start position at top right? I mean when user click (start) my winform application the winform will appear at the top right of the screen?

Answer

Use the Load event to change the position, the earliest you'll know the actual size of the window after user preferences and automatic scaling are applied:

Public Class Form1
    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        Dim scr = Screen.FromPoint(Me.Location)
        Me.Location = New Point(scr.WorkingArea.Right - Me.Width, scr.WorkingArea.Top)
        MyBase.OnLoad(e)
    End Sub
End Class