c# - 带有 AutoSize 的面板内的 FlowLayoutPanel 问题

标签 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个按钮全部可见,但Panel忘了缩小

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、按钮 7 和按钮 8 不见了

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

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

最佳答案

在我看来这像是一个错误...您可以向 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, ...

关于c# - 带有 AutoSize 的面板内的 FlowLayoutPanel 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2611313/

相关文章:

c# - Microsoft Visual Studio 专业许可

c# - 如何通过像 ASMX Web 服务一样创建它的实例来使用 WebAPI

c# - 快速高效地下载多个文件(异步)

c# - 为winform应用程序添加web前端

c++ - 在 C++ 中创建 Windows 窗体应用程序(不带 .NET)

C# 自定义组合框 - 下拉位置

c# - EF 生成的查询应为 "("

c# - 如何立即使用 INotifyPropertyChanged 通知 GUI 更改

.net - WPF根据对象属性在ContextMenu上隐藏MenuItem

c# - 如何强制在 maskedtextbox 中只允许数值?