使用自动调整大小时,FlowLayoutPanel的身高缺陷 [英] FlowLayoutPanel Height bug when using AutoSize

查看:466
本文介绍了使用自动调整大小时,FlowLayoutPanel的身高缺陷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格拿着TableLayout 1列保存2 FlowLayoutPanels 3行文本框。
中的所有行都是自动尺寸,并且列被设置为百分比= 100%。

I have a form holding a TableLayout with 1 column and 3 rows that holds 2 FlowLayoutPanels and a Text box. All Rows are AutoSize, and the column is set to Percentage=100%.

每个FlowLayoutPanel的持有多个文本框。
的FlowLayoutPanels设置:LeftToRight,自动调整大小=真,GrowAndShrink,对接=填写

Each FlowLayoutPanel holds several TextBoxes. The FlowLayoutPanels are set: LeftToRight, AutoSize=true, GrowAndShrink, Docking=Fill.

大纲是:

Form
    TableLayout (Dock=Fill)
        FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
           More controls
        FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
           More controls
        TextBox(Dock=Fill, MultiLine=true)

现在的问题是,如果我把FlowLayoutPanel的这也被设置为自动调整大小=真,FlowLayoutPanel的身高没有正确设置分组框里面,它显示了在1线切割一些文本框。文本框的表单的

The problem is if I place the FlowLayoutPanel inside a GroupBox which are also set to be AutoSize=true, the FlowLayoutPanel Height are not set correctly and it shows the TextBoxes in 1 line cutting some TextBoxes out of the form.

大纲是:

Form
    TableLayout (Dock=Fill)
        GroupBox (Dock=Fill, AutoSize=True, GrowShrink) 
            FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
               More controls
        GroupBox (Dock=Fill, AutoSize=True, GrowShrink) 
            FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
               More controls
        TextBox(Dock=Fill, MultiLine=true)

BTW,同样的事情发生,如果我用一个分组框,一个小组甚至一个用户控件来代替按住FlowLayoutPanel的。

BTW,the same thing happens if I use instead of a GroupBox, a Panel or even a UserControl to hold the FlowLayoutPanel.

BTW 2,出现这种情况即使没有TableLayout。我尝试过的自动调整大小窗体上放置分组框(与FlowLayoutPanel的),我也得到相同的行为。

BTW 2, this happens even without the TableLayout. I tried placing the GroupBox (with the FlowLayoutPanel) on an AutoSized Form and I get the same behavior.

我觉得这个问题是,当FlowLayoutPanel的是在另一个容器这也是自动调整大小失败传递给它的容器首选大小。

What I think the problem is that when the FlowLayoutPanel is in another container that is also AutoSized it fails to pass to it's container is preferred size.

可以做些什么来覆盖这个错误??

What can be done to override this bug??

请帮助
谢谢,
约拉姆

Please help Thanks, Yoram

PS:我必须使用分组框中有大约文本框一个很好的框架。

p.s: I must use the GroupBox to have a nice frame around the TextBoxes.

推荐答案

曾经遇到过这样的问题太多,并试图找出如何轻松解决这个。
虽然@ GertArnold的回答确实帮助,感觉有点麻烦,我搜索了另一种解决方案。

Had encountered this problem too, and tried to figure out how to easily resolve this. Although the @GertArnold's answer did help, it felt a bit cumbersome, and I searched for another solution.

我发现的是,流动小组的自动调整逻辑正在对最低的要求,并通过添加一个空白面板,最小高度的我能够迫使流量面板的宽度,从而使所有其他的子控件可见。

What I found was that the Flow Panel's autosize logic was working on the 'minimum' requirements, and by adding a blank Panel, of minimum height I was able to force the Flow Panel's width, thus making all other child controls to be visible.

所以在上面的最终布局的例子是:

so in the example above the final layout would be:

Form
    TableLayout (Dock=Fill)
        GroupBox (Dock=Fill, AutoSize=True, GrowShrink) 
            FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
                Panel(Dock=Fill, Height = 1, MinimumSize = new System.Drawing.Size( Form.ClientSize.Width - TableLayout.Padding.Horizontal, 1))
                More controls
        GroupBox (Dock=Fill, AutoSize=True, GrowShrink) 
            FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
                Panel(Dock=Fill, Height = 1, MinimumSize = new System.Drawing.Size( Form.ClientSize.Width - TableLayout.Padding.Horizontal, 1))
                More controls
        TextBox(Dock=Fill, MultiLine=true)

希望这有助于。

这篇关于使用自动调整大小时,FlowLayoutPanel的身高缺陷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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