I'm adding rows in the following manner:
Table.RowCount = Table.RowCount ++;
Table.RowStyles.Add(new RowStyle(System.Windows.Forms.SizeType.AutoSize));
How can I add a Label to each cell in this newly created row?
I'm adding rows in the following manner:
Table.RowCount = Table.RowCount ++;
Table.RowStyles.Add(new RowStyle(System.Windows.Forms.SizeType.AutoSize));
How can I add a Label to each cell in this newly created row?
Use the TableLayoutControlCollection.Add Method. There's an overload that allows you to specify the row and column where the new Label will be added.
This snippet adds a row to a TLP and then adds a new Label to the first column of this new row:
Label label = new Label();
label.Name = "MyNewLabel";
label.Text = "Added in my test";
tableLayoutPanel1.RowCount++;
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.Controls.Add(label, 0, tableLayoutPanel1.RowCount - 1);