63 818
Assignments Done
99,5%
Successfully Done
In August 2018

Answer to Question #63738 in C# for Peter

Question #63738
I have two forms, when I click a button on my first form it closes it and opens the 2nd form. However, when I click the default 'X' in the top right corner of the form to close it, it closes but the program's process are still left running in the background. How can I fix this to completely close the program as well?
Expert's answer
For default in windows forms in the situation that you cited above - when you close 2-nd form, process of the 1-st form will be also ended. Maybe you use Hide(), not Close(). But if you cant get it you can just write property of Owner, for example form1.Owner = form2; This means that when you close form 2 it will automatic close all like "child" forms for which is owner form2;

And the last - you can use FormClosed event and write all that you want for example Application.Exit(); - for exit from your program and closing all forms and processes.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions