采用在窗體事件SizeChanged里面代碼控制大小和位置,達到自動適應窗體大小,這樣做調整起來方便。
private void FrmMain_SizeChanged(object sender, EventArgs e) { //int grpLogWidth = (this.Width * 42) / 100; //int tabControlWidth = this.Width - grpLogWidth; int tabControlWidth = tabControl.Width; int grpLogWidth = this.Width - tabControl.Width-50; grpLog.Height = this.Height - 100; rtxtLog.Height = grpLog.Height - 60; grpLog.Width = grpLogWidth; rtxtLog.Width = grpLogWidth - 10; tabControl.Location = new Point(grpLogWidth + 20, tabControl.Location.Y); tabControl.Height = grpLog.Height - 10; dgvCalibration.Height = tabControl.Height - 70; }