我在运行时用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);
答案 0 :(得分:0)
尝试设置Padding或MinimumSize属性:
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);