c# - Automatically resize TableLayoutPanel row when window is resized -


i have simple 1x3 tablelayoutpanel. want achieve simple thing: when window resized, resize middle row , keep top , bottom ones same. tried doing logical thing, setting rigid top , bottom row sizes , autosize middle row. unfortunately, it's bottom row resizes.

//  // tablelayoutpanel1 //  this.tablelayoutpanel1.columncount = 1; this.tablelayoutpanel1.columnstyles.add(new system.windows.forms.columnstyle()); this.tablelayoutpanel1.controls.add(this.toppanel, 0, 0); this.tablelayoutpanel1.controls.add(this.middlepanel, 0, 1); this.tablelayoutpanel1.controls.add(this.bottompanel, 0, 2); this.tablelayoutpanel1.dock = system.windows.forms.dockstyle.fill; this.tablelayoutpanel1.location = new system.drawing.point(0, 0); this.tablelayoutpanel1.name = "tablelayoutpanel1"; this.tablelayoutpanel1.rowcount = 1; this.tablelayoutpanel1.rowstyles.add(new system.windows.forms.rowstyle(system.windows.forms.sizetype.absolute, 140f)); this.tablelayoutpanel1.rowstyles.add(new system.windows.forms.rowstyle()); this.tablelayoutpanel1.rowstyles.add(new system.windows.forms.rowstyle(system.windows.forms.sizetype.absolute, 24f)); this.tablelayoutpanel1.size = new system.drawing.size(1102, 492); this.tablelayoutpanel1.tabindex = 19; 

all of inner panels have dock set fill , default anchors. doing wrong?

change middle row 100% percent, tell system middle row fill gap left. change (i believe designer.cs):

this.tablelayoutpanel1.rowstyles.add(new system.windows.forms.rowstyle()); 

to:

this.tablelayoutpanel1.rowstyles.add(new system.windows.forms.rowstyle(system.windows.forms.sizetype.percent, 100f)); 

check tablelayoutpanel.rowstyle msdn:

  1. rows rowstyle set absolute considered first, , fixed heights allocated.
  2. rows rowstyle set autosize sized contents.
  3. remaining space divided among rows withrowstyle set percent.

Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

How to mention the localhost in android -

php - Calling a template part from a post -