vb.net 在visual basic中在屏幕右下角定位表单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1846352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Position form at the bottom right corner of the screen in visual basic
提问by Utku Dalmaz
How can I position a form at the bottom right corner of the screen when the form loads? I'm using Visual Basic 2010 Express.
加载表单时,如何将表单定位在屏幕的右下角?我正在使用 Visual Basic 2010 Express。
Thanks
谢谢
EDIT: I did this and it seems to work great.
编辑:我这样做了,它似乎工作得很好。
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)
采纳答案by Adriaan Stander
You need to change the Form.StartPosition to Manual and change the Location property of the form
您需要将 Form.StartPosition 更改为 Manual 并更改表单的 Location 属性
eg how to set form startup location/position manually?
or
或者
VB.net - Form Start Position Upper Left
using Form.StartPosition Property and Form.Location Property
回答by Lost
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
回答by Zunair
Center Screen:
中心屏幕:
Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2)
Right Bottom Corner Screen:
右下角屏幕:
Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)
回答by rDroid
simply this does the trick for me: poitions just above/left of taskar s the case may be.
简单地这对我有用:在 taskar 的正上方/左侧的 poitions 可能是这种情况。
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)
回答by Gordon Bell
If you want to position the form on the screen cursor is on, use:
如果要将表单定位在屏幕光标所在的位置,请使用:
' Get Active Screen Cursor is On, rather than assuming user on PrimaryScreen
Dim scr As Screen = Screen.FromPoint(Cursor.Position)
Me.Location = New Point(scr.WorkingArea.Right - Me.Width, scr.WorkingArea.Bottom - Me.Height)
回答by betrice mpalanzi
you can try like
你可以试试
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
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
回答by IT Vlogs
Try this solution. It working for me at VS 2019
试试这个解决方案。它在 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
goodluck
祝你好运
回答by Mark Cooper
You can loop through the child forms and do some calculations based on the top and left properties (might want to combine those calcs with Width and Height properties depending on what your requirement is for "bottom left")
您可以遍历子窗体并根据 top 和 left 属性进行一些计算(可能希望将这些 calcs 与 Width 和 Height 属性结合起来,具体取决于您对“左下角”的要求)
HTH, Mark
HTH,马克