在做一个多窗口的程序,打开了子窗口后关闭主窗口就全部关闭把Main改成:
         static void Main()
        {
            int count = 1;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 form1 = new Form1(count);
            form1.Show();
            Application.Run();        }后来关闭所有窗口又不关闭应用程序(进程),怎么才可以把这两个同时解决。
(附子窗口也可以打开子窗口)(如word),
请各位帮忙。

解决方案 »

  1.   

    在操作窗体的过程中,不需要的窗体可以this.Hide ,真正需要结束的时候,再调用this.Close 
      

  2.   

    在主窗体上加一个NotifyIcon和上下主菜单ContextMenuStrip,
    设置 notifyIcon1的上下文菜单为 contextMenuStrip1;
     
    NotifyIcon的点击事件中加入 
    this.Show();菜单上加一个“退出”项,在Click事件中加入
    Application.Exit();在 FormClosing 事件中加入     
            
                if (e.CloseReason == CloseReason.UserClosing)
                {
                   
                    e.Cancel = true;
                    this.Hide();
                    this.notifyIcon1.ShowBalloonTip(1, this.Text, "系统在后台运行。", ToolTipIcon.Info);
                
                }
            
      

  3.   

    有个窗体关闭事件,FormClosing事件,就是在窗体关闭之前事件,你在那个事件里面写上Application.Exit();就可以了,就是代表所有才程序都退出!这个事件写主窗体的事件!
      

  4.   

    在窗体的FormClosed中添加 Application.Exit();代码就可以实现关闭进程了呀