在主窗体上点击菜单时,如果做到每个窗体不会被重复打开,如果打开了,可以将其重新获得焦点. 首先在主窗体中将菜单关联的窗体实例化. 第二步:将每个菜单对应窗体的closing事件重写.之所以要重写closing事件,是因为在菜单对应的窗口关闭之后,再次打开就会报错 第三步:在主窗体中菜单事件里面进行判断处理 栗子如下: public partial class main : Window { //实例化关联的窗口 MainWindow m = new MainWi…
WinForm如果我们希望一次只打开一个程序,那么我们在程序每次运行的时候都需要检测线程是否存在该程序,如果存在就呼出之前的窗体,C#代码如下: using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Windows.…