简体   繁体   English

自动缩放WinForms

[英]Autoscale WinForms

Has a program written in a notebook with a resolution of 1600x900, all the elements are placed normally, and the same program on a monitor with 1920x1080 scale from 125% windows are placed incorrectly. 在笔记本中编写了一个分辨率为1600x900的程序,所有元素均正常放置,并且在125%的窗口上以1920x1080的比例在监视器上放置了相同的程序。 How on WinForms c# consider it and how to redraw? 如何在WinForms c#上考虑它以及如何重画?

By making use of anchors and docks then you should be able to create a WinForm which scales to any size monitor. 通过使用锚点和停靠点,您应该能够创建可缩放到任何大小监视器的WinForm。

It would be helpful if you could edit your question and include the designer code so we can see what's happening. 如果您可以编辑问题并包括设计者代码,这样我们将可以看到发生的情况,这将是有帮助的。

In order to make the form resize as you want, You can use table layout panels to set your layout and then you can use the anchor property of the controls to set, where they should move when the form is resized. 为了根据需要调整表单的大小,可以使用表格布局面板设置布局,然后可以使用控件的anchor属性进行设置,调整表单大小时,控件应移动到该位置。

The anchor property simply anchors the control to a location, for example if you anchor a text box to may be left, then on resize it will be at left. anchor属性只是将控件锚定到某个位置,例如,如果将文本框锚定为可能在左侧,则在调整大小时它将在左侧。 Or if you anchor it to say both left and right, if will expand in both directions. 或者,如果将其锚定为左右两个方向,则是否会向两个方向扩展。 Just explore them and it should work fine for you. 只需探索它们,它对您就可以正常工作。

You need to consider using the anchor and Dock properties this is how you position your controls on the form and control their positions in various scales 您需要考虑使用anchor和Dock属性,这是在窗体上放置控件并以各种比例控制控件位置的方式

you can find here very useful article about using anchoring and docking 您可以在此处找到有关使用锚定和停靠的非常有用的文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM