Reputation: 27342
I know I can find the screen resolution of the Primary screen easily, but I want to find the resolution of the screen that my form is currently sitting in (this is not the same on my setup I have three screens with two different resolutions)
I appreciate that the form could span more than one screen so I would be happy with finding the screen that contains the most area of the form/the top left corner
Is there a simple way to do this?
I can enumerate the screens, but then working out where my form is sitting within this is tricky:
For Each scr As Screen In Screen.AllScreens
If Me.Left > scr.WorkingArea.Left AndAlso Me.Left < (scr.WorkingArea.Left + scr.WorkingArea.Width) Then 'etc
End If
Next
Upvotes: 1
Views: 283
Reputation: 30127
I can enumerate the screens, but then working out where my form is sitting within this is tricky
.Net provides built-in method for this
Take a look at Screen.FromControl
Return Value
Type: System.Windows.Forms.Screen A Screen for the display that contains the largest region of the specified control. In multiple display environments where no display contains the control, the display closest to the specified control is returned.
Upvotes: 2