c# - How to close the main form without letting the application close?

后端 未结 3 1457
没有蜡笔的小新
没有蜡笔的小新 2021-01-16 06:59

What i want to do:
->Open a MDI form
->Close the projects main form
->Without closing the application

What i have done:

frmMain          


        
3条回答
  •  自闭症患者
    2021-01-16 07:40

    You can use the Hide method.

    Try doing this:

    frmMain fm = new frmMain();
    this.Hide();
    fm.Show();
    

    Or:

    frmMain fm = new frmMain();
    this.Hide();
    fm.ShowDialog();
    this.Show();
    

    The latter will open the window, and once it is closed, the previous window will reappear.

提交回复
热议问题