form.closing not firing

  • Thread starter Thread starter Trapulo
  • Start date Start date
T

Trapulo

I need to release some resourse when user closes a form. I tried with this
code:

Private Sub frmSimple_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

But when I close the form, it disappears but this event is not fired.

I have an other problem related with this. My main routine opens the form
with this code:

Using frmSimple As New frmSimple

Application.Run(frmSimple)

End Using



After this code I need to make some other cleanup code. But the code is
never executed, and the application remains in memory.



What is it wrong?



thanks
 
Hi!

How do you close your application? With the X in the upper right corner of
the form?

If so, that is the reson why the event is never fired, because the X just
minimize the form. Change the form:s property: MinimizeBox to false and the X
will change to an OK that closes the application and fires the event.

//MH
 
In addition to not using the minimize box, you can choose to not use the
controlbox and create your own exit button to close the form and perform
whatever logic you want on the click of the button.
 
ahh!!!

I see, thank you!


MH said:
Hi!

How do you close your application? With the X in the upper right corner of
the form?

If so, that is the reson why the event is never fired, because the X just
minimize the form. Change the form:s property: MinimizeBox to false and
the X
will change to an OK that closes the application and fires the event.

//MH
 

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

Back
Top