如何在不同的屏幕分辨率下保持Windows窗体的相对位置? [英] How to maintain relative position of windows forms in different screen resolutions?

查看:187
本文介绍了如何在不同的屏幕分辨率下保持Windows窗体的相对位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Windows窗体(form1),单击一下按钮即可打开另一个窗体(form2).我希望第二个表单始终在第一个表单上方显示100px,并且我希望第一个表单从屏幕左侧开始恰好显示600px.我可以手动编码它们的位置,但是当我在不同的屏幕分辨率下运行该程序时,它们的位置会很麻烦.
我找不到用于表单的任何停靠和锚定属性(如控件中存在的属性).
我可以通过任何方式相对于彼此以及相对于屏幕放置窗体吗?

I''m building a windows form (form1) which opens another form (form2) on the click of a button. I want the second form to always appear 100px above the first one and i want the first one to appear exactly 600px from the left side of the screen. I can manually code their positions but then when i run the program on a different screen resolution, their positions go haywire.
I don''t find find any dock and anchor properties either for the forms (like the ones present for controls).
Is there any way i can position the forms relative to each other and also to the screen?

推荐答案

没有与整个屏幕相关的停靠或锚定属性.您可以使用SystemInformation.PrimaryMonitorSize来适当地检索您形成的屏幕尺寸和位置.
There is no docking or anchor properties that relate to the overall screen. You can use SystemInformation.PrimaryMonitorSize to retrieve the screen size and position you forms appropriately.


这篇关于如何在不同的屏幕分辨率下保持Windows窗体的相对位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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