我有一個從TableLayoutPanel派生的類。此類化妝tabel糾正(網格3x8)並在一些單元格中添加一些複選框。所有這些都是通過覆蓋函數InitLayout()來完成的。覆蓋Windows(Form)控件TableLayoutPanel問題
public class TableLayoutPanelHours : TableLayoutPanel
{
protected override void InitLayout()
{
RowCount = 3;
ColumnCount = 8;
// Set some column and row styles
RowStyles[0].SizeType = SizeType.Percent;
RowStyles[0].Height = (100/RowCount);
// ... etc ...
// ... create checkbox with the name checkbox1
Controls.Add(checkbox1, 1, 1); // Put in cell 1x1
// ... etc ...
}
}
構建完成後,控件可以從VS2010的工具箱中獲得。
然後,將控件放在一個簡單的Windows窗體上,有些事情發生,我不會用戶: - 控件在設計模式下還沒化妝。 TableLayoutPanel顯示默認的2x2網格和複選框在一個奇怪的地方。運行後,控制正確顯示(3×8網格複選框在正確的地方) - 和:在InitializeComponent()形式,我認爲出現這些行:
//
// tableLayoutPanelHours1
//
this.tableLayoutPanelHours1.ColumnCount = 8;
this.tableLayoutPanelHours1.ColumnCount = 3;
this.tableLayoutPanelHours1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
// ....
我有例外,這些線在Windows窗體的InitializeComponent()中不可見,但爲什麼會發生這種情況?
謝謝。
漢斯,謝謝你的信息!克利裏。謝謝。 – robertpnl 2010-08-14 20:35:38
不客氣。並感謝您在我無法幫助的答案數量方面取得領先。 300正在接近! – 2010-08-14 23:40:54