.net - TableLayoutPanel rows & columns at runtime -
im trying build usercontrol contains tablelayoutpanel. in panel need dynamically add 3 columns each having different width , 5 rows shell have same height (20% of tablelayoutpanel's height).
column1 should have absolute width of 20, column2 depending width on content (a textbox .dock = fill) column3 width of 30.
my code:
private sub buildgui() if rows > 0 tlp.controls.clear() tlp.columnstyles.clear() tlp.rowstyles.clear() if style = styles.adding tlp.columnstyles.add(new columnstyle(sizetype.absolute, 30)) tlp.columnstyles.add(new columnstyle(sizetype.autosize)) tlp.columnstyles.add(new columnstyle(sizetype.absolute, 20)) tlp.columncount = 3 tlp.rowstyles.add(new rowstyle(sizetype.autosize, 20%)) tlp.rowstyles.add(new rowstyle(sizetype.autosize, 20%)) tlp.rowstyles.add(new rowstyle(sizetype.autosize, 20%)) tlp.rowstyles.add(new rowstyle(sizetype.autosize, 20%)) tlp.rowstyles.add(new rowstyle(sizetype.autosize, 20%)) tlp.rowcount = rows = 0 rows - 1 dim l new label dim t new textbox dim c new checkbox l .backcolor = color.aqua '.dock = dockstyle.fill .visible = true .borderstyle = windows.forms.borderstyle.fixedsingle .font = new font("microsoft sans serif", 11, fontstyle.bold) end tlp.controls.add(l, 0, i) t .backcolor = color.beige .visible = true .multiline = true .scrollbars = scrollbars.vertical .dock = dockstyle.fill end tlp.controls.add(t, 1, i) c .visible = true .backcolor = color.brown end tlp.controls.add(c, 2, i) next else end if end if
end sub
styles & rows properties of usercontrol.
but result never want be. ideas?
for struggling same:
private sub buildgui() if rows > 0 tlp.controls.clear() tlp.columnstyles.clear() tlp.rowstyles.clear() if style = styles.adding tlp.columnstyles.add(new columnstyle(sizetype.absolute, 30)) tlp.columnstyles.add(new columnstyle(sizetype.percent, 80%)) tlp.columnstyles.add(new columnstyle(sizetype.absolute, 50)) tlp.columncount = 3 = 0 rows - 1 tlp.rowstyles.add(new rowstyle(sizetype.percent, 100 / rows)) dim l new label dim t new textbox dim c new checkbox l .text = chr(65 + i) .textalign = contentalignment.middlecenter .visible = true .font = new font("microsoft sans serif", 11, fontstyle.bold) .dock = dockstyle.fill end tlp.controls.add(l, 0, i) t .name = "txt" & chr(65 + i) .visible = true .multiline = true .scrollbars = scrollbars.vertical .dock = dockstyle.fill end tlp.controls.add(t, 1, i) c .name = "chk" & chr(65 + i) .checkalign = contentalignment.middlecenter .visible = true .backcolor = color.lightgray .dock = dockstyle.fill end tlp.controls.add(c, 2, i) next else end if end if end sub
Comments
Post a Comment