By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,626 Members | 1,862 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,626 IT Pros & Developers. It's quick & easy.

Closing event not firing

P: n/a
Hi

I have a main form that contains a panel which contains a child form. The
problem is that when the main form is closed by the user, the 'closing'
event for the child form is not triggered, which I need to do some cleanup
in the child form. What is the problem and is there a workaround?

Thanks

Regards


Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
it could have something to do the way you load your child forms
i would suggest that you put a messagebox in each event that could be
activated when you close the form (closed, closing, deactivated,...)
anywhere you could put your code. this way you can track down if you could
put your code somewhere else.

hope it helps

eric
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi

I have a main form that contains a panel which contains a child form. The
problem is that when the main form is closed by the user, the 'closing'
event for the child form is not triggered, which I need to do some cleanup
in the child form. What is the problem and is there a workaround?

Thanks

Regards

Nov 20 '05 #2

P: n/a
John,

What about moving the code to the destructor? It seems like you should be
able to add a Finalize method to the class to do your cleanup code.

Keith Fink
Microsoft Developer Support
Visual Basic .NET

Nov 20 '05 #3

P: n/a
I have tried this in the child form;

Protected Overrides Sub Finalize()
MsgBox("I am here")
DoUpdate() ' My last cleanup here.
MyBase.Finalize()
End Sub

This does not get called either. :(

"Keith Fink (MS)" <ke****@onlinemicrosoft.com> wrote in message
news:Rr**************@cpmsftngxa06.phx.gbl...
John,

What about moving the code to the destructor? It seems like you should be
able to add a Finalize method to the class to do your cleanup code.

Keith Fink
Microsoft Developer Support
Visual Basic .NET

Nov 20 '05 #4

P: n/a
What about the Dispose method of the parent form?
Nov 20 '05 #5

P: n/a
I ended up using closing of the parent form and that is where I am doing the
final bits for child form.

One would think that a form's closing will always be called even if it is a
child form??!! Hmmm...something for the next version.
"Keith Fink (MS)" <ke****@onlinemicrosoft.com> wrote in message
news:zs**************@cpmsftngxa06.phx.gbl...
What about the Dispose method of the parent form?

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.