VB.Net 表单 - MDI 表单未正确定位

发布于 2024-12-24 16:28:36 字数 917 浏览 3 评论 0原文

我对 MDI 表单及其位置有疑问。我有一个容器表单,在其中打开多个子表单。另请注意,在容器表单中,我在顶部有一个 ToolStrip,并且它也停靠在顶部。在每个子表单中,我设置了以下属性。我也在设计时设置了它们,但由于某种原因它不起作用,所以我也将它们放在 form_load 事件中。

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Dock = DockStyle.Fill
ReSizeAndArrange(Me.Width, Me.Height, False)

form_loadform_layout 事件上调用函数 ReSizeAndArrange。我遇到的问题是子表单没有正确填充剩余空间或整个父表单。当我单步执行时,这是我为子表单获取的坐标。

frmContainer.Size   {Width = 972 Height = 972}  System.Drawing.Size
me.Size     {Width = 968 Height = 901}  System.Drawing.Size
frmContainer.ToolStripMain.Size {Width = 954 Height = 67}   System.Drawing.Size
frmContainer.Location   {X = 90 Y = 22} System.Drawing.Point
me.Location     {X = -9 Y = -36}    System.Drawing.Point

Me.Location 不应该是 0,0 吗?这些数字加起来就是我认为的尺寸。 4 个像素的差异或许可以通过边界来解释,但具体位置却无法解释。有人能破译这个吗?

I have a problem with MDI forms and their location. I have a container form within which I open several child forms. Also note that in the container form I have a ToolStrip at the top and it is also docked to the top. In each of the child forms I have set the following properties. I have set them at design time as well but it wasn't working for some reason so I put them in the form_load event as well.

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Dock = DockStyle.Fill
ReSizeAndArrange(Me.Width, Me.Height, False)

The function ReSizeAndArrange is called on form_load and form_layout events. The problem I am having is that the child forms do not fill the remaining space correctly or for that matter the entire parent form. When I step through, here are the coordinates I am getting for the child form.

frmContainer.Size   {Width = 972 Height = 972}  System.Drawing.Size
me.Size     {Width = 968 Height = 901}  System.Drawing.Size
frmContainer.ToolStripMain.Size {Width = 954 Height = 67}   System.Drawing.Size
frmContainer.Location   {X = 90 Y = 22} System.Drawing.Point
me.Location     {X = -9 Y = -36}    System.Drawing.Point

Shouldn't the Me.Location be 0,0? The numbers add up on the sizes I think. The 4 pixel difference can perhaps be explained by the border, however, the location is unexplained. Can anyone decipher this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

亢潮 2024-12-31 16:28:36

好的,我自己解决了这个问题,只需将窗体的位置设置为(0,0)即可。它仍然没有回答问题,但它是一个解决方法。

OK, I solved the problem myself simply by setting the location of the form to (0,0). It still doesn't answer the question, but it is a workaround.

空城旧梦 2024-12-31 16:28:36

这是因为 0, 0 不会对表单大小/布局施加限制。它允许它做出决定。您输入的任何值都会强制表单符合您的规格。 0, 0 不是一种解决方法,它是“你自己决定”的做法。

It's because 0, 0 doesn't put constraints on the form size/layout. It allows it to decide. Any value you put in there forces the form to conform to YOUR specs. 0, 0 isn't a work around, it's the "you decide this yourself form" way of doing it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文