vb.NET Screen Location

962 Views Asked by At

I'm working with a multi monitor setup. I know that you can do Screen.AllScreens(x) to get a specific screen, but is there any way to identify which screen is in which position?

I.E.

Screen 0 is on the right, screen 1 is on the left, screen 2 is in the middle

I'm trying to position one form at the top left of each screen, and the only way i can think to do this is something like

Me.Location = New Point(-Screen.AllScreens(1).Bounds.Width, Screen.AllScreens(1).Bounds.Top)

(That is assuming that screen 1 is on the left)

Any help?

Wrapping it in some sort of a loop that would autogenerate the forms for each screen would be amazing too, but i can handle that myself. I just need to know how to position each one at the top left of each screen..

Thanks :3

1

There are 1 best solutions below

2
On BEST ANSWER

As I mentioned on another site, if I'm understanding you correctly then something like this should do as you want:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim number = 1

    For Each scr In Screen.AllScreens.OrderBy(Function(s) s.Bounds.Left)
        Dim f As New Form With {.Text = number.ToString(),
                                .StartPosition = FormStartPosition.Manual,
                                .Location = scr.Bounds.Location}

        f.Show()

        number += 1
    Next
End Sub