【问题标题】:Problems with FlowLayoutPanel inside Panel with AutoSize带有 AutoSize 的面板内的 FlowLayoutPanel 问题
【发布时间】:2010-04-09 22:17:34
【问题描述】:

我有以下控件层次结构:

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

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

【问题讨论】:

  • 我在 FlowLayoutPanel 上看到过类似的问题。它似乎是越野车。正如 simon 所建议的,您可以经常(但不总是)使用 TableLayoutPanels 来实现您所需要的。

标签: c# .net winforms panel autosize


【解决方案1】:

在我看来它像一个错误...您可以向 Microsoft 报告。

一种可能的解决方法:尝试使用 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, ...

【讨论】:

  • 谢谢!这是有效的,除了调整大小的丑陋动画,但它的布局没有错误! :-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-16
  • 1970-01-01
  • 2010-11-07
相关资源
最近更新 更多