简体   繁体   English

c#winforms均匀分配3个控件

[英]c# winforms evenly distribute 3 controls

i have 3 custom controls, that i want to place in a resizable window next to each other. 我有3个自定义控件,我想放在一个可调整大小的窗口彼此相邻。 when the window is being resized, these controls should also resize, each taking 33% of the available width. 调整窗口大小时,这些控件也应调整大小,每个控件占可用宽度的33%。

i tried to use a table layout, but it seems the table only grows, but never shrinks. 我试图使用表格布局,但似乎表格只会增长,但从不收缩。

thanks for any help on this! 感谢您的帮助!

You can use a TableLayoutPanel, with 3 columns each of size "33% percent". 您可以使用TableLayoutPanel,其中3列各自的大小为“33%”。 Then you put each of your control in the panel, and set the anchor property as you wish (for example right-left if your control should resize themselves only on the horizontal plane). 然后将每个控件放在面板中,并根据需要设置锚属性(例如,如果控件应仅在水平面上调整大小,则为右 - 左)。

Your TableLayoutPanel should also have its property Dock set to True so that he can occupy all your window and resize accordingly. 您的TableLayoutPanel也应将其属性Dock设置为True,以便他可以占用您的所有窗口并相应地调整大小。

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

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