如何降低组框的默认高度?

时间:2013-11-25 13:22:22

标签: c# winforms

我在运行时用dock top绘制一个组合框,在其中我绘制了固定高度和宽度的按钮组框的Autosize属性为true。我正在绘制的按钮的高度低于在运行时获取的组框的默认高度。如何删除组框的额外底部空间?

GroupBox gbFreeCust = new GroupBox() 
    { 
        Dock= DockStyle.Top, 
        Text = item.CatName, 
        AutoSize = true, 
        AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowOnly 
    };
pnlFreeCust.Controls.Add(gbFreeCust);

1 个答案:

答案 0 :(得分:0)

尝试设置PaddingMinimumSize属性:

GroupBox gbFreeCust = new GroupBox() 
    { 
        Dock= DockStyle.Top, 
        Text = item.CatName, 
        AutoSize = true, 
        AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowOnly,
        Padding = new System.Windows.Forms.Padding(0),
        MinimumSize = new Size(0,0)
    };
pnlFreeCust.Controls.Add(gbFreeCust);