Closed event not getting called?

  • Thread starter Thread starter YYZ
  • Start date Start date
Y

YYZ

I've got a form in my application. From this form, I showdialog
another form, like this:

dim f as new frmWhatever
f.someprop = somevalue
f.showdialog()
f.OkToClose = True
f.close
f = nothing

On the dialog type form, I have a property called OkToClose. If the
user closes the dialog form by using the control menu, then in the
form.Closing event, I have this:

if OkToClose = False then
e.cancel = true
me.hide
exit sub
end if

So, the form doesn't get Closed when the user "closes" it -- it gets
Closed when my code on the parent form sets OkToClose = True and then
calls f.Close.

I have code in the frmWhatever.Close event, and it NEVER gets called,
as far as I can tell. Is there a reason for this? Am I missing
something?

Matt
 
Be sure that when you are done with the form, that you call it's
Dispose method. That is not automatically called when you close it,
unlike a form shown with just the Show method.
 
Back
Top