如何在不同的屏幕分辨率下保持Windows窗体的相对位置?

编程入门 行业动态 更新时间:2024-10-13 02:15:55
本文介绍了如何在不同的屏幕分辨率下保持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窗体的相对位置?

本文发布于:2023-10-08 01:14:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471079.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   屏幕分辨率   位置   如何在   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!