我正在使用C#编写Winforms应用程序。我想设置我的程序,以便如果一个窗体关闭,程序将终止或停止。我已经知道如何选择将首先打开的窗体。
这是我程序中的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MainMenu
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Login());
}
}
}
我希望能够设置我的login.cs表单,这样如果该表单被关闭,程序将终止。这种情况是否可能发生?