public MainForm() { InitializeComponent(); axialImage = new ImageControl(Axis.AxialAxis); axialImage.Dock = DockStyle.Fill; sagittalImage = new ImageControl(Axis.SagittalAxis); sagittalImage.Dock = DockStyle.Fill; coronalImage = new ImageControl(Axis.CoronalAxis); coronalImage.Dock = DockStyle.Fill; this.tableLayout1x1 = new TableLayoutPanel(); this.tableLayout1x1.Dock = DockStyle.Fill; this.tableLayout1x1.RowCount = 1; this.tableLayout1x1.ColumnCount = 1; this.tableLayout1x1.RowStyles.Clear(); this.tableLayout1x1.ColumnStyles.Clear(); for (int i = 0; i < this.tableLayout1x1.RowCount; i++) { this.tableLayout1x1.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / this.tableLayout1x1.RowCount)); } for (int i = 0; i < this.tableLayout1x1.ColumnCount; i++) { this.tableLayout1x1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / this.tableLayout1x1.ColumnCount)); } this.tableLayout2x2 = new TableLayoutPanel(); this.tableLayout2x2.Dock = DockStyle.Fill; this.tableLayout2x2.RowCount = 2; this.tableLayout2x2.ColumnCount = 2; this.tableLayout2x2.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; this.tableLayout2x2.RowStyles.Clear(); this.tableLayout2x2.ColumnStyles.Clear(); for (int i = 0; i < this.tableLayout2x2.RowCount; i++) { this.tableLayout2x2.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / this.tableLayout2x2.RowCount)); } for (int i = 0; i < this.tableLayout2x2.ColumnCount; i++) { this.tableLayout2x2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / this.tableLayout2x2.ColumnCount)); } this.panel1.Controls.Add(tableLayout2x2); this.Load += Form1_Load; }
void Form1_Load(object sender, EventArgs e) { tableLayoutPanel1.SuspendLayout(); axialImage = new ImageControl(Axis.AxialAxis); axialImage.Dock = DockStyle.Fill; axialPanel.Controls.Add(axialImage); //tableLayoutPanel1.Controls.Add(axialImage, 0, 0); sagittalImage = new ImageControl(Axis.SagittalAxis); sagittalImage.Dock = DockStyle.Fill; sagittalPanel.Controls.Add(sagittalImage); //tableLayoutPanel1.Controls.Add(sagittalImage, 1, 0); coronalImage = new ImageControl(Axis.CoronalAxis); coronalImage.Dock = DockStyle.Fill; coronalPanel.Controls.Add(coronalImage); //tableLayoutPanel1.Controls.Add(coronalImage, 2, 0); tableLayoutPanel1.ResumeLayout(); MessageBox.Show("Done"); }