与FlowLayoutPanel有关的问题 - 更改AutoScroll和WrapContens [英] Problem wiht FlowLayoutPanel - changing AutoScroll and WrapContens

查看:180
本文介绍了与FlowLayoutPanel有关的问题 - 更改AutoScroll和WrapContens的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在运行时更改WrapContents = true时,如何控制FlowLayoutPanel获得水平滚动条?



情况:

在FlowLayoutPanel中有几个大小相等的元素。

流向是TopDown。



默认为WrapContens为false,显示所有元素彼此下方,当面板尺寸太小时,我得到一个垂直滚动条。



任务:

如果宽度为FlowLayoutPanel已更改且> = 2 *元素宽度,设置WrapContents = true。



问题:

如果我设置WrapContens =在运行时为true,并且换行创建超过2列,我没有水平滚动条。



但是如果在设计时设置了WrapContens = true,那么我得到了正在运行的程序中的水平滚动条。





感谢您的任何想法。

解决方案

现在我找到了一个解决方案,使用FlowLayoutPanel玩游戏。



更改WrapContents时,AutoScroll必须设置为false:



< pre lang =c#> this .AutoScroll = false ;
.WrapContents = .Width > ; = this .Controls [ 0 ]。宽度* 2 ;
.AutoScroll = true ;





然后会显示正确的滚动条。



行为未记录在任何地方。非常神秘。


How can I control the FlowLayoutPanel that I get a horizontal scrollbar when I change WrapContents=true at runtime?

The situation:
In the FlowLayoutPanel are several equal-sized elements.
Flow Direction is TopDown.

Default is WrapContens to false, all elements are displayed below each other, and when the panel size is too small, I get a vertical scrollbar.

The task:
If the width of the FlowLayoutPanel is changed and >= 2 * element width, set WrapContents=true.

The problem:
If I set WrapContens=true at runtime, and the wrap creates more than 2 columns, I get no horizontal scrollbar.

But if WrapContens=true is set at design time, then I get the horizontal scroll bar in the running program.


Thanks for any idea.

解决方案

Now I found a solution myself, playing around with the FlowLayoutPanel.

The AutoScroll must set to false while changing the WrapContents:

this.AutoScroll = false;
this.WrapContents = this.Width >= this.Controls[0].Width * 2;
this.AutoScroll = true;



Then the correct scroll bars will be displayed.

The behavior is not documented anywhere. Very mysterious.


这篇关于与FlowLayoutPanel有关的问题 - 更改AutoScroll和WrapContens的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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