Windows Forms: Change application mainwindow at runtime

前端 未结 1 857
余生分开走
余生分开走 2020-12-04 00:59

Normally I would do Application.Run(myMainForm).

But I want to do something like this:

MyForm1 f = new MyForm1();
f.Close+=OnOpenOverviewWin();
Appli         


        
相关标签:
1条回答
  • 2020-12-04 01:33

    Set the Application.ShutdownMode property to ShutdownMode.OnLastWindowClose

    MyForm1 f = new MyForm1();
    f.Close += OnOpenOverviewWin();
    Application.ShutdownMode = ShutdownMode.OnLastWindowClose;
    Application.Run(f);
    
    void OnOpenOverviewWin()
    {
      MyOverViewForm f = new MyOverViewForm ();
      f.Show();
    }
    
    0 讨论(0)
提交回复
热议问题