gpt4 book ai didi

c# - 在辅助监视器上显示 Windows 窗体?

转载 作者:IT王子 更新时间:2023-10-29 04:05:39 25 4
gpt4 key购买 nike

我正在尝试在辅助监视器上设置 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;
}

边界的属性似乎是正确的,但在我尝试过的两种方法中,这都会最大化主监视器上的表单。有什么想法吗?

最佳答案

this.Location = Screen.AllScreens[1].WorkingArea.Location;

这是表单引用。

关于c# - 在辅助监视器上显示 Windows 窗体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1363374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com