This sample code shows how to Show windows form on dual monitor
- function void showOnMonitor1()
- {
- Screen[] sc;
- sc = Screen.AllScreens;
- //get all the screen width and heights
- Form2 f = new Form2();
- f.FormBorderStyle = FormBorderStyle.None;
- f.Left = sc[0].Bounds.Width;
- f.Top = sc[0].Bounds.Height;
- f.StartPosition = FormStartPosition.Manual;
- f.Location = sc[0].Bounds.Location;
- Point p = new Point(sc[0].Bounds.Location.X, sc[0].Bounds.Location.Y);
- f.Location = p;
- f.WindowState = FormWindowState.Maximized;
- f.Show();
- }
複製代碼
- function void showOnMonitor2()
- {
- Screen[] sc;
- sc = Screen.AllScreens;
- //get all the screen width and heights
- Form2 f = new Form2();
- f.FormBorderStyle = FormBorderStyle.None;
- f.Left = sc[1].Bounds.Width;
- f.Top = sc[1].Bounds.Height;
- f.StartPosition = FormStartPosition.Manual;
- f.Location = sc[1].Bounds.Location;
- Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
- f.Location = p;
- f.WindowState = FormWindowState.Maximized;
- f.Show();
- }
複製代碼 |