C# 窗体 |表格边界厚度

C# Winforms | Form-border thickness

是否有关于常规表格的边框有多粗的文档?

目标:
我创建了一个宽度为 800px 的 userControl。我想以全分辨率(800px - 一切可见)用它的新实例引发一个弹出窗口(一般是正常形式)。

我的问题: 将表单设置为 Form.Size.Width = 800 不会这样做。看起来表单的边框包含在表单的 width-属性 中。我需要减去那个边框。

我应该是这样的: 2px + 800px + 2px

如果你想看一些代码告诉我,但我认为这里没有必要。

编辑:

弹出控件后:

弹出代码:

private void buttonPopup_Click(object sender, EventArgs e)
{
    Form MyPopup = new Form();
    customControl MyUserControl = new customControl();

    MyUserControl.Dock = DockStyle.Fill;

    Rectangle rc = MyUserControl.RectangleToScreen(MyUserControl.ClientRectangle);

    //int thickness = SystemInformation.Border3DSize.Width;
    //MyPopup.MaximumSize = new Size(MyUserControl.Size.Width + (thickness*2), 1500);

    MyPopup.Controls.Add(MyUserControl);
    MyPopup.MaximumSize = new Size(rc.Width, rc.Height);
    MyPopup.Show();
}

我的意思是你的代码对我来说看起来合乎逻辑。但结果仍然是一样的。 userControl 显示的稍微小一点。我知道我已经使用 dock = fill 按钮没有专业地放置在布局内。但是除此之外,必须有一个解决方案来 设置正确的大小

看来你正在寻找

int thickness = SystemInformation.Border3DSize;

另一种(和 INHO,更好 的一种)可能性是使用 ClientRectangle 控件。例如:

// Client rectangle in screen coordinates
Rectangle rc = MyControl.RectangleToScreen(MyControl.ClientRectangle);

// Let's align context menu (its width) to bottom of the control
MyContextMenuStrip.AutoSize = false;
// Depending on actual dropdown control you may want align either via
//   Width = rc.Width;
// Or 
//   ClientSize = new Size(rc.Width, someHeight);
MyContextMenuStrip.Width = rc.Width;

// Let's show context menu at the bottom of the control
MyContextMenuStrip.Show(new Point(rc.Left, rc.Bottom));