我想给WINFORM的程序加个这样的功能,点一个button则注销(或者说退出)当前系统,然后启动登陆界面。
我想应该不是hide()当前,再show()主窗口吧?
请高手指教。

解决方案 »

  1.   

    很久没做winform的了 ,应该可以close了 在show主窗体
      

  2.   

    我理解楼主的意思是在Form1中点击按钮关闭Form1,然后自动启动Form2。这样的话可以在Form1中设置一个public bool bBtnQuitPressed; 点击按钮后处理该变量,然后在获取Form1的DialogResult的代码地方判断此变量,根据变量情况,调用Form2。
      

  3.   

     Application.Restart();用这句就可以实现了。
      

  4.   

    谢谢LS的各位,但是如果这样写要怎么写?
    Application.Current.Shutdown();
                    System.Diagnostics.Process PP = new System.Diagnostics.Process();
                    PP.Start();
                    System.Reflection.Assembly.GetEntryAssembly();
      

  5.   

     Login MyLogin = new Login();
                MyLogin.Show();
                this.Dispose();
    这样就行了啊
      

  6.   

    说实话 就可以用你自己说的方法
    先hide 再show
    为什么不行呢?
    只要能实现需求就可以了
      

  7.   

    已经解决了,谢谢各位。WPF的,以下代码供参考。  private void MenuISystem_Click(object sender, RoutedEventArgs e)
            {//退出系统代码
                if ((e.Source as MenuItem).Header.ToString().Trim() == "退出系统")
                {
                    if (MessageBox.Show("是否退出系统?", "确认退出", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Yes, MessageBoxOptions.DefaultDesktopOnly) == MessageBoxResult.Yes)
                    {
                        isResert = true;
                        Application.Current.Shutdown();
                    }
                }
                else
                {//注销系统代码
                   // Application.Current.Shutdown();               
                    isResert = true;
                    Application.Current.Shutdown();
                    ResertSystem();
                }
            }        private void ResertSystem()
            {
                System.Reflection.Assembly.GetEntryAssembly(); 
                string startpath = System.IO.Directory.GetCurrentDirectory();
                System.Diagnostics.Process.Start(startpath + "/WpfApplication1.exe");
            }