How can I get my windows form to do something when it is closed.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Handle the
FormClosedevent.To do that, go to the Events tab in the Properties window and double-click the
FormClosedevent to add a handler for it.You can then put your code in the generated
MyForm_FormClosedhandler.You can also so this by overriding the
OnFormClosedmethod; to do that, typeoverride onformclin the code window andOnFormClosedfrom IntelliSense.If you want to be able to prevent the form from closing, handle the
FormClosingevent instead, and sete.Canceltotrue.