c# - Add Row Dynamically in TableLayoutPanel -
i want add these entries dynamically row row in tablelayoutpanel in windows form in c#
how can that?
try 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); // add new row (loop code 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 = "xxxxxxx@gmail.com" }, 3, panel.rowcount-1);
Comments
Post a Comment