110,534
社区成员
发帖
与我相关
我的任务
分享
protected override void OnLoad(EventArgs e)
{
foreach (Control c in Controls)
{
var k = new RectangleF(
(float)c.Left / (float)Width,
(float)c.Top / (float)Height,
(float)c.Width / (float)Width,
(float)c.Height / (float)Height);
c.Tag = k;
}
}
private void Form1_SizeChanged(object sender, EventArgs e)
{
foreach (Control c in Controls)
{
var k = (RectangleF)c.Tag;
c.Left = (int)(k.X * Width);
c.Top = (int)(k.Y * Height);
c.Width = (int)(k.Width * Width);
c.Height = (int)(k.Height * Height);
}
}
panel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;