Search code examples
vb.netmultiple-monitors

Move Form if second monitor screen exists


Looking for a way to load a from if a second screen exists.

I have tried this code with a load event:

Dim numofMon As Integer = Screen.AllScreens.Length
If numofMon > 1 Then
            Me.Bounds = Screen.AllScreens(1).Bounds
        End If

Side note: If someone could point me to how to detect when the cursor is no longer on the form, I would appreciate it.


Solution

  • This ended up working for me.

    Dim obj as New Form2
    obj.Location = Screen.AllScreens(UBound(Screen.Allscreens)).Bounds.Location
    obj.show()