C# 窗体程序 所有控件按照分辨率只适应的缩放
在窗体里面还几百个控件 都要进行自适应的放大和缩小 如果一个一个的添加就太繁琐了 该怎么写可以省事些
程序代码:unsafe private void Form2_Load(object sender, EventArgs e)
{
Rectangle rect = new Rectangle();//声明一个rect
rect = Screen.PrimaryScreen.Bounds;//获取当前屏幕的分辨率
int width, height;//声明宽度,高度
width = int.Parse(rect.Width.ToString());
height = int.Parse(rect.Height.ToString());//将高度宽度赋值
ctlAppearance_position(Width, Height);
}
private void ctlAppearance_position(int Width, int Height)
{
button1.Location = new Point(Width * 116 / 1034, Height * (-28) / 780);
button1.Size = new Size(Width * 58 / 1034, Height * 23 / 780);
button10.Location = new Point(Width * 183 / 1034, Height * 95 / 780);
button10.Size = new Size(Width * 15 / 1034, Height * 15 / 780);
}
这个是实现的代码 求教育啊。。。。。








