如何在 WinForms 中制作屏幕分辨率感知程序

How to make a screen resolution aware program in WinForms

大家好,我有一个问题,我在屏幕分辨率为 1600x900 的环境中设计了一个程序,问题是当我尝试以其他分辨率(例如 1366x768)执行程序时,我所有的按钮、面板等,被 window 裁剪,这里是 1600x900 的示例 Example and here at 1366x768 Example 我使用了锚点和填充属性但它不起作用,你知道任何 属性 或解决这个问题的方法吗,我会万分感谢

核心 属性 也尝试使用拆分容器,它会根据分辨率自动调整表单大小

尝试在表单加载时使用此代码

public void abrunden(object was, int x, int y, int width, int height, int radius)
{

    System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

    gp.AddLine(x + radius, y, x + width - radius, y);
    gp.AddArc(x + width - radius, y, radius, radius, 270, 90);
    gp.AddLine(x + width, y + radius, x + width, y + height - radius);
    gp.AddArc(x + width - radius, y + height - radius, radius, radius, 0, 90);
    gp.AddLine(x + width - radius, y + height, x + radius, y + height);
    gp.AddArc(x, y + height - radius, radius, radius, 90, 90);
    gp.AddLine(x, y + height - radius, x, y + radius);
    gp.AddArc(x, y, radius, radius, 180, 90);
    gp.CloseFigure();

    was.region = new System.Drawing.Region(gp);
    gp.Dispose();
}

调用此使用以下

  1. 在表单中使用一个面板将其与表单对接

  2. 将面板名称宽度和高度传递给方法

abrunden(panWarten, 0, 0, _with1.Width, _with1.Height, 20);

这将使表单根据屏幕响应