本文介绍了如何确保在窗体显示"附加的QUOT;在双显示器的场景监控?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,其中有我想要显示第二个屏幕上的表单。

I have an application in which there is a form which I want to show on second screen.

的意思是如果应用程序在屏幕上运行,当我菜单上单击显示的形式,它应该显示在屏B
 和同样的,如果与应用程序在屏幕B上运行,当我点击菜单上的显示形式,它应该显示在屏幕上。

Mean If application is running on screen A and when I click on menu to show Form it should display on Screen B and same with if application is running on screen B and when I click on menu to show Form it should display on Screen A.

推荐答案

您需要使用班找一个屏幕,原来的形式不上,然后根据该屏幕的界限设置第二个窗体的位置属性

You need to use the Screen class to find a screen that the original form is not on, then set the second form's Location property based on that screen's Bounds.

例如:

var myScreen = Screen.FromControl(originalForm);
var otherScreen = Screen.AllScreens.FirstOrDefault(s => !s.Equals(myScreen))
               ?? myScreen;
otherForm.Left = otherScreen.WorkingArea.Left + 120;
otherForm.Top = otherScreen.WorkingArea.Top + 120;

这将任意数量的屏幕工作。

This will work for any number of screens.

请注意,这是可能的,该视频卡被配置成使得Windows看到一个大屏幕,而不是两个较小的,在这种情况下,这变得更加困难。

Note that it is possible that the video card is configured so that Windows sees one large screen instead of two smaller ones, in which case this becomes much more difficult.

这篇关于如何确保在窗体显示"附加的QUOT;在双显示器的场景监控?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 16:17