- 在
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();
}
本文介绍了一种在Windows应用程序中实现窗口间平滑切换的方法。通过设置一个公共静态布尔变量作为标志位,在关闭当前窗口的同时打开另一个窗口。这种方法适用于需要在不同窗体间进行逻辑关联的应用场景。
807

被折叠的 条评论
为什么被折叠?



