Is there a way to direct a form in VB.NET to open and maximize in the second monitor. That is if there are two monitors displayed, to have the form load in the second window maximized by default?
Say a program was made with two forms and a computer has two monitors attached.
I want FormA to show in MonitorA by default and FormB to show in MonitorB maximized by default.
EDIT: Further edited for clarity.
The first thing is to get information about available screens. You can get that from Screen.AllScreens
. Next is to determine how many screens there are (note that there may be more than two). Then you need to decide how to identify the "second" screen (for instance, the first one that where the Primary
property is false
.
When that is done, I guess that the simplest way is to move the form to a location that is within the Bounds
of the desired screen, and then maximize it.
Here is a sample method that opens a form maximized on a specified screen:
public static void ShowMaximizedOnScreen(Screen screen, Form form)
{
form.Location = screen.Bounds.Location;
form.WindowState = FormWindowState.Maximized;
form.StartPosition = FormStartPosition.Manual;
form.Show();
}