我需要调整表单大小并使其占据屏幕的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)
但它没有中心,任何人都可以帮忙吗?
答案 0 :(得分:1)
您只更改尺寸; 改变我。位置;还需要做一些数学计算:)
类似的问题,答案很好: Position form at the bottom right corner of the screen in visual basic
答案 1 :(得分:0)
解决方案
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)