winforms 调整控件以在其他人不可见时垂直向上推 [英] winforms adjust controls to push up vertically when others are invisible

查看:20
本文介绍了winforms 调整控件以在其他人不可见时垂直向上推的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个 c# winforms 表单,

I've create a c# winforms form,

它有一堆标签和一个flowlayoutpanel.

It has a bunch of labels positioned and a flowlayoutpanel.

在某些情况下,我将其中一个标签和 flowlayoutpanel 设置为可见 =false.

on certain occasions i set one of the labels and the flowlayoutpanel to visible =false.

因此,我希望将它们下方的所有标签向上推 - 目前它们所在的位置存在间隙.

As a result i want all labels beneath them to be pushed up - at the moment there is a gap where they were.

另外,我希望 flowlayoutpanel 根据它拥有的项目数量来增长和缩小.目前它只是我在设计器中设置的尺寸.

Also, I'd like the flowlayoutpanel to grow and shrink depending on the number of items it has. at the moment it is just the size i set it to be in the designer.

请您帮忙解决这两个问题.

please can you help with these 2 issues.

谢谢

推荐答案

如果我没听错,我建议您使用两行的 TableLayoutPane.顶行将包含一个停靠面板,其中包含可能隐藏的所有控件.底行将包含一个停靠面板和其他所有面板.

If I got you correctly, I would suggest using a TableLayoutPane with two rows. The top row will contain a docked panel with all the controls that may be hidden. The bottom row will contain a docked panel with all the rest.

将顶行的 SizeType 设置为 AutoSize,将底行的 SizeType 设置为 100%.

Set the top row's SizeType to AutoSize and the bottom row's to 100%.

如果要隐藏控件,请将顶部面板的 Visible 属性设置为 false.现在,因为顶行是 AutoSized,所以它会缩小到零,导致底行跳"起来.

When you want to hide the controls, set the top panel's Visible property to false. Now, because the top row is AutoSized it will shrink to nothing, causing the bottom row to "jump" up.

这篇关于winforms 调整控件以在其他人不可见时垂直向上推的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆