我正在尝试在辅助监视器上设置Windows窗体,如下所示:
private void button1_Click(object sender, EventArgs e)
{
MatrixView n = new MatrixView();
Screen[] screens = Screen.AllScreens;
setFormLocation(n, screens[1]);
n.Show();
}
private void setFormLocation(Form form, Screen screen)
{
// first method
Rectangle bounds = screen.Bounds;
form.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height);
// second method
//Point location = screen.Bounds.Location;
//Size size = screen.Bounds.Size;
//form.Left = location.X;
//form.Top = location.Y;
//form.Width = size.Width;
//form.Height = size.Height;
}
Run Code Online (Sandbox Code Playgroud)
边界的属性似乎是正确的,但在我尝试的两种方法中,这最大化了主监视器上的表单.有任何想法吗?
我有一个应用程序,其中有一个表单,我想在第二个屏幕上显示.
平均值如果应用程序在屏幕A上运行,当我单击菜单以显示表格时,它应显示在屏幕B上,如果应用程序在屏幕B上运行,当我单击菜单显示表格时,它应显示在屏幕A上.