VB.NET表单位置到底部

时间:2015-02-27 18:28:53

标签: vb.net winforms position

这可能是一个愚蠢的问题......但是如何在VB.NET中从屏幕底部加载Windows窗体? 我尝试使用表单位置,但它只有中心屏幕ETC. :( 还试过这段代码......但不完全是我想要的......

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)

我正在创建一个在最大化模式下运行的应用程序,因此它可以填满整个屏幕。我希望应用程序有自己的键盘(一个带键的按键形式!)必须出现在底部(就像键盘出现在任何Android / IOS手机的屏幕底部

1 个答案:

答案 0 :(得分:2)

如果您希望表单位于主屏幕底部的中心,则可以在表单的Load事件处理程序中使用此代码。

Dim x As Integer = (Screen.PrimaryScreen.WorkingArea.Width - Me.Width) \ 2
Dim y As Integer = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Me.Location = New Point(x, y)

在您的评论中,您询问是否将表单放在屏幕底部但填充屏幕宽度。你可以这样做。

Dim y As Integer = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Me.Location = New Point(0, y)
Me.Width = Screen.PrimaryScreen.WorkingArea.Width