显示在辅助监视器上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?
推荐答案
尝试设置WindowStartUpLocation参数设置为手动你SetFormLocation方法内。
Try setting WindowStartUpLocation parameter as "manual" inside your SetFormLocation method.
这篇关于显示在辅助监视器上Windows窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文