在扩展屏幕上显示表单 [英] Display form on extended screen

查看:101
本文介绍了在扩展屏幕上显示表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在扩展显示器上显示表单。单击按钮后,下面是我的代码:

I want to display the form on the extended monitor. Below is my code after clicking a button:

primaryDisplay = Screen.AllScreens.ElementAtOrDefault(0);
extendedDisplay = Screen.AllScreens.FirstOrDefault(s => !s.Equals(primaryDisplay)) ?? primaryDisplay;
this.StartPosition = FormStartPosition.Manual;
this.Location = extendedDisplay.Bounds.Location;
this.Show();



但是,表格仍显示在主要表格上。我的代码有什么问题?谢谢。



我的尝试:



扩展后的展示表格屏幕不成功


However, the form is still displayed on the primary one. What is wrong in my code? Thanks.

What I have tried:

Display Form on Extended Screen not successful

推荐答案

在我看到的任何地方都没有定义返回屏幕的顺序:你需要检查Screen.Primary Property(System.Windows.Forms) [ ^ ]而不是依赖于收集中的第一个:

The order in which the screens are returned is not defined anywhere I can see: you need to check the Screen.Primary Property (System.Windows.Forms)[^] rather than rely on the first in the colection:
primaryDisplay = Screen.AllScreens.FirstOrDefault(s => s.Primary);
extendedDisplay = Screen.AllScreens.FirstOrDefault(s => !s.Primary) ?? primaryDisplay;
StartPosition = FormStartPosition.Manual;
Location = extendedDisplay.Bounds.Location;
Show();


这篇关于在扩展屏幕上显示表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆