c# - Adjusting column/row width/height based on the number of them -
i have tablelayoutpanel
2 rows , 2 columns called gamegrid
.
when button1
pressed want:
a column , row added,
all columns adjusted equal widths,
all rows adjusted equal heights.
this i've tried far:
//add new row , row style gamegrid.rowcount++; gamegrid.rowstyles.add(new system.windows.forms.rowstyle(system.windows.forms.sizetype.absolute, 10)); //change rowstyles entire width / number of rows foreach (rowstyle style in this.gamegrid.rowstyles) { style.sizetype = sizetype.percent; style.height = gamegrid.width / gamegrid.rowcount; } //do same columns gamegrid.columncount++; gamegrid.columnstyles.add(new system.windows.forms.columnstyle(system.windows.forms.sizetype.absolute, 10)); foreach (columnstyle style in this.gamegrid.columnstyles) { style.sizetype = sizetype.percent; style.width = gamegrid.height / gamegrid.columncount; }
but doesn't quite work , end this:
why last column/row longer rest, , work instead?