tablelayoutpanel内部组件变形

时间:2021-10-22 08:46:12

tablelayoutpanel设为dock=full后,最大化或最小化窗口会变形。

解决办法:加入flowlayoutpanel,将tablelayoutpanel放入其中,然后在tablelayoutpanel的Paint事件加入调整窗口相关的方法。

private void tableLayoutPanel6_Paint(object sender, PaintEventArgs e)        
{            
  SetTableSize();        
}

public void SetTableSize()        
{            
  this.tableLayoutPanel6.Width = this.flowLayoutPanel1.Width - 3;            
  this.tableLayoutPanel6.Height = this.flowLayoutPanel1.Height - 3;        
}
其中tableLayoutPanel6.dock=none.,完美解决问题。