1
我有一个TableLayoutPanel的问题,它填充了一个userControl(DockStyle.Fill)。我面临一个麻烦,当这个控件被调整大小时,我需要所有的单元格来改变它们的大小,但是只有最后一行和最后一列的大小发生了变化(所以整个tableLayoutPanel填充了控件)。我使用Bounds属性更改此控制器大小。Scaling WinForms TableLayoutPanel
比方说,我写了下面的代码:
// creating tableLayoutPanel:
private void createTableLayoutPanel(int count)
{
tableLayoutPanel = new TableLayoutPanel();
tableLayoutPanel.MouseClick += new MouseEventHandler(this.observe_MouseClick);
tableLayoutPanel.AutoSize = true;
tableLayoutPanel.ColumnCount = 3;
tableLayoutPanel.RowCount = count;
tableLayoutPanel.Dock = DockStyle.Fill;
tableLayoutPanel.AutoSize = true;
this.Controls.Add(tableLayoutPanel);
}
// resizing:
private void OnMouseWheel(MouseEventArgs e)
{
this.Bounds = new Rectangle(this.Location.X, this.Location.Y, (int)(this.Width*newScale),(int)(this.Height*newScale));
}
感谢您的帮助。