日期:2014-05-18 浏览次数:20876 次
public partial class Form1 : Form { private List<double> dPresentW = new List<double>(); private List<double> dPresentH = new List<double>(); private List<double> dPresentT = new List<double>(); private List<double> dPresentL = new List<double>(); public Form1() { InitializeComponent(); foreach (Control ctl in this.Controls) { dPresentW.Add((double)ctl.Width / (double)Width); dPresentH.Add((double)ctl.Height / (double)Height); dPresentT.Add((double)ctl.Top / (double)Top); dPresentL.Add((double)ctl.Left / (double)Left); } } private void Form1_Resize(object sender, EventArgs e) { int count = Controls.Count; for (int i = 0; i < count; ++i) { Controls[i].Width = (int)(dPresentW[i] * Width); Controls[i].Height = (int)(dPresentH[i] * Height); Controls[i].Top = (int)(dPresentT[i] * Top); Controls[i].Left = (int)(dPresentL[i] * Left); } } }