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?
1
Expert's answer
2016-12-04T03:56:12-0500
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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS