简体   繁体   English

如何使表单最大化到Windows窗体应用程序中的任何计算机屏幕?

[英]How can you make the form maximize to any computer screen in a Windows Forms application?

So I am making a game on Visual Studio C# and I want the form to be automatically maximized to any user's computer screen when compiled? 所以我在Visual Studio C#上制作游戏,我希望在编译时将表单自动最大化到任何用户的计算机屏幕? How can I do that? 我怎样才能做到这一点?

You can do it using one of the following -- 您可以使用以下方法之一来完成 -

  1. Set the form WindowState = FormWindowState.Maximized; 设置窗体WindowState = FormWindowState.Maximized;
  2. Get the screen resolution using following code and set the size of your forms accordingly 使用以下代码获取屏幕分辨率,并相应地设置表单的大小

     int height = Screen.PrimaryScreen.Bounds.Height; int width = Screen.PrimaryScreen.Bounds.Width; 

Set the WindowState property of your form to Maximized . 将窗体的WindowState属性设置为Maximized

That will cause your form to be maximumized when it's opened. 这将导致您的表单在打开时最大化。

你可以使用this.WindowState = FormWindowState.Maximized;

  1. Go To Load Form As View Code and use This Code : 转到加载表单作为查看代码并使用此代码:

C#: C#:

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

VB: VB:

Me.WindowState = System.Windows.Forms.FormWindowState.Maximized

If you are looking for something that will maximize your window on a first click and normalizes your window on a second click, this will help. 如果您正在寻找能够在第一次点击时最大化窗口并在第二次点击时标准化窗口的内容,这将有所帮助。

private void maximiseButton_Click(object sender, EventArgs e)
    {

        //normalises window
        if (this.WindowState == FormWindowState.Maximized)
        {
            this.WindowState = FormWindowState.Normal;
            this.CenterToScreen();
        }

        //maximises window
        else
        {
            this.WindowState = FormWindowState.Maximized;
            this.CenterToScreen();
        }
    }

在VS2010中更正:

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

On the Form Move Event add this: 在表单移动事件上添加以下内容:

    private void Frm_Move (object sender, EventArgs e)
    {
        Top = 0; Left = 0;
        Size = new System.Drawing.Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows窗体的任务栏上最大化应用程序? - How to maximize application in over the Taskbar at Windows Forms? 如何使用 c# windows 窗体应用程序制作计时器以关闭计算机 - How to make a timer to shutdown computer with c# windows form application 在C#中,您可以将Windows窗体应用程序作为服务启动吗? - In C#, can you make a windows form application start as a service? 如何在Windows窗体应用程序中创建Alt快捷方式? - How can you create Alt shortcuts in a Windows Forms application? 如何在 Windows 窗体应用程序中设计自定义关闭、最小化和最大化按钮? - how to design a custom close, minimize and maximize button in windows form application? 如何使C#Windows窗体应用程序适合屏幕 - How to make a C# Windows Form Application fit to the screen 如何在Windows窗体应用程序中获取当前窗体? - How can I get the current form in a Windows Forms application? 如何在 windows 窗体应用程序中构建启动画面? - How to build splash screen in windows forms application? 如何使C#.net中Windows窗体应用程序的连接字符串独立于计算机? - How to make the connection string of an Windows form application in C#.net,Computer independent? 当我们的C#应用​​程序中有多个Windows窗体时,如何制作一个窗体作为打开窗体 - When we have multiple windows forms in our C# application, how to make one form as opening form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM