如何使我的表格填满当前屏幕上的整个屏幕

时间:2019-03-14 11:36:28

标签: vb.net

我正在做一个项目,我需要使Form填满整个屏幕

            Me.Height = Screen.PrimaryScreen.Bounds.Height
            Me.Width = Screen.PrimaryScreen.Bounds.Width
            Me.FormBorderStyle = FormBorderStyle.None
            Me.Location = New Point(Screen.AllScreens(0).Bounds.X, 
            Screen.AllScreens(0).Bounds.Y)
            Me.Height = Screen.PrimaryScreen.Bounds.Height
            Me.Width = Screen.PrimaryScreen.Bounds.Width
            Me.FormBorderStyle = FormBorderStyle.None

这可以填充整个屏幕,无论是哪个屏幕为主屏幕,我的问题是使用1台以上的显示器(我使用3台)时,如何获取表格处于启用状态并使其全屏显示的屏幕该屏幕,而不仅仅是跳到我的主屏幕?

2 个答案:

答案 0 :(得分:0)

没关系,我再喝一点咖啡...

        Me.Height = Screen.FromControl(Me).Bounds.Height
        Me.Width = Screen.FromControl(Me).Bounds.Width
        Me.FormBorderStyle = FormBorderStyle.None
        Me.Location = New Point(Screen.FromControl(Me).Bounds.X, 
        Screen.FromControl(Me).Bounds.Y)
        Me.Height = Screen.FromControl(Me).Bounds.Height
        Me.Width = Screen.FromControl(Me).Bounds.Width
        Me.FormBorderStyle = FormBorderStyle.None

答案 1 :(得分:0)

WinForm上有一个名为WindowState的属性。将此设置为最大化。该表格将自动填写整个监视器。

Form1.WindowState = Maximized