How to register for events of a form closing?

C

cyberco

I want myHandler to be invoked when myForm (Form) closes, so I added an
eventhandler to Form.Closing as follows:

========================================
myForm.Deactivate += new EventHandler(myHandler);

void myHandler(object sender, EventArgs e) {
Debug.WriteLine("==myHandler invoked");
}
========================================

Unfortunately myHandler never gets called. Whether I use Form.Closed,
Form.Closing, Form.Deactivate,...

What am I doing wrong here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top