Hello,
I have a system with two monitors connected, using two screens.
I need set in my winforms application in wich screen my form is displayed.
How I can do this
Thanks
Josep M
Girona
Hello,
I have a system with two monitors connected, using two screens.
I need set in my winforms application in wich screen my form is displayed.
How I can do this
Thanks
Josep M
Girona
Display form in multiple screens
SteveDyte
OK, Thanks.
I have assigned the workingarea.x value to left property of my form. But also, I need to establish the startposition to manual in orden to obtain the desired results.
Josep M Busquets
Girona
Aguila
Take a look at the screen info available in the Screen class (from System.Windows.Forms).
One example of this that ONLY works if your monitors are in a horizontal line next to each other is:
int runningWidth = 0;
Screen furthestLeft = Screen.PrimaryScreen;
foreach (Screen screen in Screen.AllScreens)
{
//Count width of all screens - Assumes all are in a single horizontal line
runningWidth += screen.WorkingArea.Width;
//Determine which screen is the furthest to the left - Needed for determining forms start position
if (furthestLeft.Bounds.X > screen.Bounds.X)
{
furthestLeft = screen;
}
}
//Set form's position to upper left corner of furthest left monitor.
this.Left = furthestLeft.WorkingArea.X;
this.Top = furthestLeft.WorkingArea.Y;
//Set forms size to width of avalible area and height of working area on primay monitor - Assumes taskbar is on primary monitor.
this.Width = runningWidth;
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
If the monitors are in any other shape then you’d need to build a fair amount of logic to decide on which set of monitors the form would be displayed.
stan_siu
Thaks for your response.
This work fine, but is not my requirements.
I need create two differents forms, and display one form in each monitor.
I have tried assigning the width value of one monitor to left property of the second form, but both forms are displayed in primary monitor.
Thanks
JMBC
Girona
Damon Tivel MSFT
Woops, I must have missed that part.
In that case, use the WorkingArea property of the Screens class to give you the available sizes and locations for each form.