我从Form1创建Form2.我想在第二台显示器上打开Form2.我怎么能这样做?我用这个代码:
private void button1_Click(object sender, EventArgs e)
{
Form2 dlg = new Form2();
dlg.Show();
}
Run Code Online (Sandbox Code Playgroud)
如何为此更改此代码?谢谢大家.
使用此代码
Form2 dlg = new Form2();
Screen[] screens = Screen.AllScreens;
Rectangle bounds = screen[1].Bounds;
dlg.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height);
dlg.StartPosition = FormStartPosition.Manual;
dlg.Show();
Run Code Online (Sandbox Code Playgroud)