简体   繁体   中英

how can I restart winform?

I have two windows form in C# . f1 calls f2.I use message box.if the user press 'ok' , the program most restart f2 again and if press 'cancel',program close f2. for pressing 'ok' : I couldn't use 'Application.restart()',because all program restarted and I just want to restart f2. when I use " f2 f=new(); f.show();this.close();" all program closed.

please learn to me how can I solve this problem? thank you.

Don't do this.Close(); after showing f . Instead, just hide your form.

f2 f = new f2();
f.Show();
this.Hide();

f1 will they stay running and you can reuse it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM