在辅助监视器上显示 Windows 窗体? [英] Showing a Windows form on a secondary monitor?
本文介绍了在辅助监视器上显示 Windows 窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在辅助监视器上设置 Windows 窗体,如下所示:
I'm trying to set a Windows Form on secondary monitor, as follows:
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;
}
边界的属性似乎是正确的,但是在我尝试过的两种方法中,这都最大化了主监视器上的表单.有什么想法吗?
The properties of bounds seem correct, but in both methods I've tried, this maximizes the form on the primary monitor. Any ideas?
推荐答案
尝试在 SetFormLocation
方法中将 StartPosition 参数设置为 FormStartPosition.Manual
.
Try setting StartPosition parameter as FormStartPosition.Manual
inside your SetFormLocation
method.
这篇关于在辅助监视器上显示 Windows 窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文