我正在构建一个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窗体的相对位置?
发布评论