【新手】如何咱按钮被单击时仅关闭当前窗口
【新手】怎么咱按钮被单击时仅关闭当前窗口
我用exit的时候就会关闭全部窗口,
退出按钮被单击时指关闭当前窗口求解!
------解决方案--------------------
一般是隐藏当前窗体,再打开新窗体。因为本窗体关闭后就不能执行里面的代码了。
必须要求先关闭的话,可以另开一个线程使用委托实现
------解决方案--------------------
主窗口先隐藏吧,this.Hide()
等f3关闭的时候调用Application.Exit()关闭整个程序。
------解决方案--------------------
如果是主窗体的话用this.Hide()隐藏掉,主窗体一关会全部都关的。
其他窗体用this.Close()吧
------解决方案--------------------
f3.Show();
this.Close();
如果是MainForm被Close 整个程序是会退出的,如果这里的this不是主窗口
f3.Show(主窗口)
this.Close();
------解决方案--------------------
this.hide();主窗体
this.close();this.dispose();子窗体
------解决方案--------------------
f3.Show();
this.Close();
------解决方案--------------------
Thread ShowMainThread = new Thread(new ThreadStart(delegate { System.Windows.Forms.Application.Run(new Form1()); }));
ShowMainThread.ApartmentState = ApartmentState.STA;
ShowMainThread.Start();
// log.Info("登陆成功" + "登陆的账号是" + Name + "密码 是" + Password);
this.Close();
this.Dispose();
我用exit的时候就会关闭全部窗口,
退出按钮被单击时指关闭当前窗口求解!
------解决方案--------------------
一般是隐藏当前窗体,再打开新窗体。因为本窗体关闭后就不能执行里面的代码了。
必须要求先关闭的话,可以另开一个线程使用委托实现
this.Close();
System.Threading.Thread thread = new System.Threading.Thread(delegate()
{ FrmNew frm = new FrmNew();
frm.ShowDialog();
});
------解决方案--------------------
主窗口先隐藏吧,this.Hide()
等f3关闭的时候调用Application.Exit()关闭整个程序。
------解决方案--------------------
如果是主窗体的话用this.Hide()隐藏掉,主窗体一关会全部都关的。
其他窗体用this.Close()吧
------解决方案--------------------
f3.Show();
this.Close();
如果是MainForm被Close 整个程序是会退出的,如果这里的this不是主窗口
f3.Show(主窗口)
this.Close();
------解决方案--------------------
this.hide();主窗体
this.close();this.dispose();子窗体
------解决方案--------------------
f3.Show();
this.Close();
------解决方案--------------------
Thread ShowMainThread = new Thread(new ThreadStart(delegate { System.Windows.Forms.Application.Run(new Form1()); }));
ShowMainThread.ApartmentState = ApartmentState.STA;
ShowMainThread.Start();
// log.Info("登陆成功" + "登陆的账号是" + Name + "密码 是" + Password);
this.Close();
this.Dispose();