Csharp/C#教程:WinForms调整控件以及窗体resize分享


WinForms调整控件以及窗体resize

我在c#WinForms应用程序中有一些控件(组框,表格,gridview等),我想根据屏幕宽度/高度来缩放它们。

例如,屏幕从让我们说640×480开始,然后它最大化到1920×1200。

我无法增加控件的宽度/高度,因此在窗口重新resize后它们看起来完全相同。

如果不手动设置每个宽度/高度属性,最好的方法是什么?

如果不手动设置每个宽度/高度属性,最好的方法是什么?

您可以使用AnchorDock属性来控制根据其包含元素进行缩放,而不是指定宽度和高度。

或者,您可以使用TableLayoutPanelFlowLayoutPanel来排列控件。

我相信你想要的是控件的Anchor属性。

顾名思义,此属性强制控件将自身锚定在父窗体或控件内的相对位置或绝对位置。 此属性有四个值可以打开或关闭:

 Top -- Indicates that the control should keep its top edge stationary in respect to the parent form (or control) top edge. Bottom -- Indicates that the control should keep its bottom edge stationary in respect to the parent form (or control) bottom edge. Left -- Indicates that the control should keep its left edge stationary in respect to the parent form (or control) left edge. Right -- Indicates that the control should keep its right edge stationary in respect to the parent form (or control) right edge. 

IIRC您想要的是使用Ctrl + A选择表单上的所有控件,然后将锚属性设置为顶部,底部,左侧和右侧。

上述就是C#学习教程:WinForms调整控件以及窗体resize分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1006191.html

(0)
上一篇 2021年12月28日
下一篇 2021年12月28日

精彩推荐