2013-11-25 41 views
0

我正在繪製一個組合框在運行時與碼頭頂部,並在裏面我繪製固定高度和寬度按鈕組框的Autosize屬性是真實的。我正在繪製的按鈕的高度低於在運行時獲取的組框的默認高度。我怎樣才能刪除組合框的額外底部空間?如何減少組合框的默認高度?

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

你就不能設置組框的上按鈕的人的高度?像'groupbox.height = max(button1.height,button2.height)+ margin'? – OlivierH

回答

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);