Programming with Dual Monitors

  • Thread starter Thread starter Ben Dunn
  • Start date Start date
B

Ben Dunn

Is there a way to control which monitor a form is displayed in with VB .NET?
We are running on Windows XP with a Matrox Dual Monitor card.
 
Ben,
Set the Bounds property of the Form to within the Bounds of one of your
Screens (monitors).

You can use System.Windows.Forms.Screen.AllScreens to get an array of Screen
objects for each Monitor that you have attached.

For example, I use the following the Load event of one of my forms.

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Dim s As Screen
For Each s In Screen.AllScreens
If Not s.Primary Then Exit For
Next
Me.Bounds = s.Bounds
Me.WindowState = FormWindowState.Maximized
End Sub

Which causes the form to be full screen on the first non-primary (the
second) monitor attached...

Hope this helps
Jay
 
Back
Top