How To Show Form To Secondary Monitor In Visual Studio

How To Show Form To Secondary Monitor In Visual Studio


Hello everyone, in this tutorial I will discuss about how to display the form to a different monitor. So we have a monitor connected device that we use to run the program, then in the program we will try to call a form and bring it up on the monitor that was connected earlier. This tutorial can be used for presentations that allow us to display outpot programs on different monitors.

I made this tutorial using the Visual Studio 2010 IDE with the Windows 7 operating system. If you use Visual Studio in another version it doesn't matter. And most importantly, do the configuration below.

Before we start coding, make sure your device is connected to a monitor / tv using an HDMI cable. If you have, do the Screen Resolution configuration as shown below


Screen 1 : The device we use to run the program
Screen 2 : Monitor/TV
Now open your Visual Studio and create a new project. then, make one more form so we have 2 Forms. Form1 where we call Form2 which will appear in Monitor / TV.

Add a Button in Form1 and then enter the following code

Public Class Form1
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click   
       Dim screen As Screen
       screen = screen.AllScreens(1)
       Form2.StartPosition = FormStartPosition.Manual
       Form2.Location = screen.Bounds.Location + new Point (100, 100)
   End Sub
End Class

Now the program is ready to run.

For more details, please watch the video below

Powered by Blogger.