调整大小并将表单居中至屏幕的 80%

发布于 2024-12-20 03:25:08 字数 405 浏览 2 评论 0原文

我需要调整我的表单大小并使其占据屏幕的 80%,目前,这就是我所拥有的,

 Dim Sw As Integer = CInt(Screen.PrimaryScreen.Bounds.Width * 0.8)
        Dim Sh As Integer = CInt(Screen.PrimaryScreen.Bounds.Height * 0.8)
        Dim nTaskBarHeight As Integer = Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom
        Me.Size = New Size(Sw, Sh - nTaskBarHeight)

但它不居中,任何人都可以帮忙吗?

I need to resize my form and make it occupy 80% of the screen, currently, this is what i have

 Dim Sw As Integer = CInt(Screen.PrimaryScreen.Bounds.Width * 0.8)
        Dim Sh As Integer = CInt(Screen.PrimaryScreen.Bounds.Height * 0.8)
        Dim nTaskBarHeight As Integer = Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom
        Me.Size = New Size(Sw, Sh - nTaskBarHeight)

But it does not center, can anyone help?

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

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

发布评论

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

评论(2

毁梦 2024-12-27 03:25:08

您仅更改尺寸;
也改变我的位置;仍然需要做一些数学计算:)

类似的问题有很好的答案:
职位表单在 Visual Basic 中屏幕右下角

You are changing only Size;
change Me.Location too; still need do some math for it :)

similar question with great answer:
Position form at the bottom right corner of the screen in visual basic

浅语花开 2024-12-27 03:25:08

解决方案

Dim Sw As Integer = CInt(Screen.PrimaryScreen.WorkingArea.Width * 0.8)
Dim Sh As Integer = CInt(Screen.PrimaryScreen.WorkingArea.Height * 0.8)
Me.Size = New Size(Sw, Sh)
Dim x As Integer = Screen.PrimaryScreen.WorkingArea.Width \ 2 - Me.Width \ 2
Dim y As Integer = Screen.PrimaryScreen.WorkingArea.Height \ 2 - Me.Height \ 2
Me.Location = New Point(x, y)

The solution

Dim Sw As Integer = CInt(Screen.PrimaryScreen.WorkingArea.Width * 0.8)
Dim Sh As Integer = CInt(Screen.PrimaryScreen.WorkingArea.Height * 0.8)
Me.Size = New Size(Sw, Sh)
Dim x As Integer = Screen.PrimaryScreen.WorkingArea.Width \ 2 - Me.Width \ 2
Dim y As Integer = Screen.PrimaryScreen.WorkingArea.Height \ 2 - Me.Height \ 2
Me.Location = New Point(x, y)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文