如何给tablelayoutpanel指定100%的宽度,以便填充父容器并在调整窗口大小时调整表格大小。如何让表格布局适合容器的100%
我的表单现在看起来是这样的:
我要动态地添加行,所以结果会有些这样的:
这将是,如果不错桌子将适合splitcontainer面板。有人知道如何做到这一点?
这是我当前的代码行添加到表:
tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset;
tableLayoutPanel1.GrowStyle = TableLayoutPanelGrowStyle.AddRows;
tableLayoutPanel1.Controls.Add(new Label() { Text = "first row:", Anchor = AnchorStyles.Left, AutoSize = true });
tableLayoutPanel1.Controls.Add(new Label() { Text = "second row:", Anchor = AnchorStyles.Left, AutoSize = true });
tableLayoutPanel1.Controls.Add(new Label() { Text = "third row:", Anchor = AnchorStyles.Left, AutoSize = true });
tableLayoutPanel1.Controls.Add(new Label() { Text = "4th row:", Anchor = AnchorStyles.Left, AutoSize = true });
tableLayoutPanel1.Controls.Add(new Label() { Text = "5th row:", Anchor = AnchorStyles.Left, AutoSize = true });
tableLayoutPanel1.Controls.Add(new Label() { Text = "6th row:", Anchor = AnchorStyles.Left, AutoSize = true });
tableLayoutPanel1.Controls.Add(new Label() { Text = "7th row:", Anchor = AnchorStyles.Left, AutoSize = true });
我可以设置列和行的宽度或100%的高度,我怎么能只在桌子至100% ?
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(754, 169);
//this.tableLayoutPanel1.Size = new System.Drawing.Size(100F, 169);//pseudo code
this.tableLayoutPanel1.TabIndex = 0;
啊,这是更容易,我认为。谢谢! – botenvouwer
不要忘记将其标记为答案。 Regards – Nath
可以在3分钟内接受答案...... – botenvouwer