I want to add these entries dynamically row by row in TableLayoutPanel in Windows Form in c#
How can I do that?
Try the below code,
// TableLayoutPanel Initialization TableLayoutPanel panel = new TableLayoutPanel(); panel.ColumnCount = 3; panel.RowCount = 1; panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F)); panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F)); panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F)); panel.RowStyles.Add(new RowStyle(SizeType.Absolute, 50F)); panel.Controls.Add(new Label() { Text = "Address" }, 1, 0); panel.Controls.Add(new Label() { Text = "Contact No" }, 2, 0); panel.Controls.Add(new Label() { Text = "Email ID" }, 3, 0); // For Add New Row (Loop this code for add multiple rows) panel.RowCount = panel.RowCount + 1; panel.RowStyles.Add(new RowStyle(SizeType.Absolute, 50F)); panel.Controls.Add(new Label() { Text = "Street, City, State" }, 1, panel.RowCount-1); panel.Controls.Add(new Label() { Text = "888888888888" }, 2, panel.RowCount-1); panel.Controls.Add(new Label() { Text = "[email protected]" }, 3, panel.RowCount-1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With