如何在表单加载时将表单放在屏幕的右下角?我正在使用Visual Basic 2010 Express。
由于
编辑:我这样做了,看起来效果很好。Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width - 400
y = Screen.PrimaryScreen.WorkingArea.Height - 270
Me.Location = New Point(x, y)
答案 0 :(得分:8)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Visible = True
Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width
y = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Do Until x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
x = x - 1
Me.Location = New Point(x, y)
Loop
End Sub
答案 1 :(得分:6)
您需要将Form.StartPosition更改为Manual并更改表单的Location属性
例如how to set form startup location/position manually?
或
答案 2 :(得分:4)
中心屏幕:
Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2)
右下角屏幕:
Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)
答案 3 :(得分:3)
这对我来说就是这样的伎俩:案例可能就是在任务的上方/左侧的位置。
Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
y = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Me.Location = New Point(x, y)
答案 4 :(得分:1)
如果要将屏幕上的表格放置在光标上,请使用:
x, y, width, height, language
答案 5 :(得分:1)
你可以尝试
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.StartPosition = FormStartPosition.Manual
Me.Location = Screen.GetWorkingArea(Me).Location
End Sub
答案 6 :(得分:0)
您可以遍历子表单并根据顶部和左侧属性进行一些计算(可能希望将这些计算与Width和Height属性结合起来,具体取决于您对“左下角”的要求)
HTH, 标记
答案 7 :(得分:0)
尝试此解决方案。它在VS 2019上对我有用
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Me.Top = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - Me.Height
Me.Left = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - Me.Width
MyBase.OnLoad(e)
End Sub
好运