Hi,
I have a class which derived from the TableLayoutPanel. This class makeup the tabel corrects (grid 3x8) and add some checkboxes in some cells. All this is done by overriding the function InitLayout().
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 ...
}
}
After building, the Control is available from the Toolbox of VS2010.
Then, putting the control on a simple Windows Form, some things are happen that I don't userstand: - the control is not makeup yet during design mode. The TableLayoutPanel is displaying the default 2x2 grid and checkboxes are on a strange place. After runtime, the control is displaying correctly (3x8 grid with Checkbox on the correctly places) - And: in the InitializeComponent() of the Form, I see these lines appears:
//
// tableLayoutPanelHours1
//
this.tableLayoutPanelHours1.ColumnCount = 8;
this.tableLayoutPanelHours1.ColumnCount = 3;
this.tableLayoutPanelHours1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
// ....
I have excepted that these lines are not visible in the InitializeComponent() of the Windows Forms, but why is this happen?
Thanks.