Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Normally I would do Application.Run(myMainForm).

But I want to do something like this:

MyForm1 f = new MyForm1();
f.Close+=OnOpenOverviewWin();
Application.Run(f);

void OnOpenOverviewWin()
{
MyOverViewForm f = new MyOverViewForm ();
Application.Run(f); // i want to do this
Application.NewMainWindow = f; // or something like that
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
296 views
Welcome To Ask or Share your Answers For Others

1 Answer

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();
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...