在Program.cs
里面加一个标志位public static bool FormOnClose { get; set; }
在需要关闭的窗口内将该标志位置真当标志位为真的时候运行需要打开的窗口即可
具体代码如下
using System;using System.Windows.Forms;using XCore.Controls.Utility;namespace VacuumFurnaceAcquisitionSystem{static class Program{public static bool FormOnClose { get; set; }/// <summary>/// 应用程序的主入口点。/// </summary>[STAThread]static void Main(){Configuration.Initialize();if (ApplicationInstance.IsFirst()){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new FormLoad());if (FormOnClose)Application.Run(new FormMain());}else{Configuration.Show("程序已打开,请勿重复点击");}}}}
标志位置真
private void buttonEnsure_Click(object sender, EventArgs e){Program.FormOnClose = true;Close();}