并非所有实例都会出现此问题,但此代码块:
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)。正如我所说,在其他代码块中,第一个控件位于左侧,第二个位于右侧。所以我试图了解是什么造成了不同。有人可以解释为什么会这样吗?