Introduction
This code is a simple test to move a Windows Forms application to anywhere in a multiple monitor environment.
Using the code
At application startup, the program takes the screen names.
for (int i = 0; i < Screen.AllScreens.Length; i++)
{
cbMonitor_id.Items.Add(Screen.AllScreens[i].DeviceName);
}
You can put any location (CoodX-CoordY) and the desired screen, then when you press the button, the application executes.
SetMonitor(this, ((cbMonitor_id.SelectedIndex>-1)?cbMonitor_id.SelectedIndex:0),
System.Convert.ToInt32(edCoordX.Text), System.Convert.ToInt32(edCoordY.Text));
And here is the display code:
void SetMonitor(Form form, int monitor_id, int x, int y)
{
Screen screen = Screen.AllScreens[monitor_id];
form.StartPosition = FormStartPosition.Manual;
x = screen.Bounds.Location.X + x;
y = screen.Bounds.Location.Y + y;
form.Location = new Point(x,y);
form.Show();
}