除了此代码块之外,所有实例都不会发生此问题:
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60.99398F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 39.00602F));
this.tableLayoutPanel1.Controls.Add(this.pbxInspectionDisplay, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.gbxEggInput, 0, 0);
this.tableLayoutPanel1.Location = new System.Drawing.Point(10, 57);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(1182, 570);
this.tableLayoutPanel1.TabIndex = 28;
在表格布局中,pbxInspectionDisplay意外地位于右侧,gbxEggInput位于左侧。如果我用以下代码替换上面的相应部分
this.tableLayoutPanel1.Controls.Add(this.gbxEggInput, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.pbxInspectionDisplay, 0, 0);
它们位于正确的顺序(左边是pbxInspectionDisplay,右边是gbxEggInput)。正如我所说,在其他代码块中,第一个控件位于左侧,第二个控件位于右侧。所以我试图了解是什么造成了不同。有人可以解释为什么会这样吗?
答案 0 :(得分:2)
我相信你想要specify the column添加控件。像这样:
this.tableLayoutPanel1.Controls.Add(this.pbxInspectionDisplay, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.gbxEggInput, 1, 0);