使用AutoSize在Panel中的FlowLayoutPanel出现问题

时间:2010-04-09 22:17:35

标签: c# .net winforms panel autosize

我有以下控件层次结构:

Form
  Panel (AutoSize = true, AutoSizeMode = GrowAndShrink, Dock = Top)
    FlowLayoutPanel (AutoSize = true, AutoSizeMode = GrowAndShrink, Dock = Top)
      Control1, Control2, Control3, Control4, ...
    FlowLayoutPanel (AutoSize = true, AutoSizeMode = GrowAndShrink, Dock = Top)
      Control1, Control2, Control3, Control4, ...

以下是各种尺寸的布局:

完全可见所有8个按钮,但面板忘了收缩

Fully visible all 8 buttons, but the Panel forgot to shrink http://img534.imageshack.us/img534/3575/panels1.png

第一个FlowLayoutPanel完全可见,但第二个只有一半可见,button8缺失

The first FlowLayoutPanel are fully visible, but the second is only half visible, button8 is missing http://img301.imageshack.us/img301/5296/panels2.png

第一个FlowLayoutPanel完全可见,但第二个只有一半可见,button7和button8缺失

The first FlowLayoutPanel are fully visible, but the second is only half visible, button7 and button8 are missing http://img697.imageshack.us/img697/4644/panels3.png

第一个FlowLayoutPanel完全可见,但第二个只有四分之一可见,按钮6,button7和button8缺失

The first FlowLayoutPanel are fully visible, but the second is only quarter visible, button 6, button7 and button8 are missing http://img168.imageshack.us/img168/6428/panels4.png

如你所见,我对这种行为并不满意。 我能做些什么来完成所有这些工作吗?

1 个答案:

答案 0 :(得分:1)

在我看来,它就像一个错误...你可以向微软报告。

一种可能的解决方法:尝试使用tableLayoutPanel而不是外部面板。像这样:

Form
    TableLayoutPanel (1 column, 2 rows with 50% size type)
        FlowLayoutPanel1 (AutoSize = true, in first row of the TableLayoutPanel, Dock = Fill)
            Button1, Button2, Button3, Button4, ...
        FlowLayoutPanel2 (SutoSize = true, in second row of the TableLayoutPanel, Dock = Fill)
            Button1, Button2, Button3, Button4, ...