Form.Close method does not fire Form_Closing or Form_Closed events 
Author Message
 Form.Close method does not fire Form_Closing or Form_Closed events

I have a form with a menuitem the calls Me.Close().  I
have code in the Form_Closing event to store application
parameters and then I have code in the Form_Closed event
that calls Application.Exit().

I can step through the code in the MenuItem_Click event
and see that the Me.Close() method is called but niether
event method seems to be called and the application never
exits.  Any clues as to why?



Mon, 07 Feb 2005 21:40:43 GMT  
 Form.Close method does not fire Form_Closing or Form_Closed events
Mark,

It sounds weird, but I recall that when I mess about with some of the code I
somtimes accidentally "remove" the Handles statement right after the
procedure declaration. Has this happened in your case, does
<FormName>_Closing event have a Handles MyBase.Closing statement after the
procedure declaration?

Just guessing here...

--
Carsten Thomsen
Snr .NET Systems Architect
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
.NET Services
http://www.dotnetservices.biz

Quote:
> I have a form with a menuitem the calls Me.Close().  I
> have code in the Form_Closing event to store application
> parameters and then I have code in the Form_Closed event
> that calls Application.Exit().

> I can step through the code in the MenuItem_Click event
> and see that the Me.Close() method is called but niether
> event method seems to be called and the application never
> exits.  Any clues as to why?



Mon, 07 Feb 2005 22:36:45 GMT  
 Form.Close method does not fire Form_Closing or Form_Closed events
Yes, both events have the correct Handles Mybase.(event
name) code in the method declaration.

Mark

Quote:
>-----Original Message-----
>Mark,

>It sounds weird, but I recall that when I mess about

with some of the code I
Quote:
>somtimes accidentally "remove" the Handles statement
right after the
>procedure declaration. Has this happened in your case,
does
><FormName>_Closing event have a Handles MyBase.Closing
statement after the
>procedure declaration?

>Just guessing here...

>--
>Carsten Thomsen
>Snr .NET Systems Architect
>Enterprise Development with VS .NET, UML, and MSF
>http://www.apress.com/book/bookDisplay.html?bID=105
>..NET Services
>http://www.dotnetservices.biz


>> I have a form with a menuitem the calls Me.Close().  I
>> have code in the Form_Closing event to store
application
>> parameters and then I have code in the Form_Closed
event
>> that calls Application.Exit().

>> I can step through the code in the MenuItem_Click event
>> and see that the Me.Close() method is called but
niether
>> event method seems to be called and the application
never
>> exits.  Any clues as to why?

>.



Mon, 07 Feb 2005 22:46:39 GMT  
 Form.Close method does not fire Form_Closing or Form_Closed events
The following code shows 2 msgboxes for me and exits the application.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Me.Close()

End Sub

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed

MsgBox("Closed")

End Sub

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

MsgBox("Closing")

End Sub


Quote:
> I have a form with a menuitem the calls Me.Close().  I
> have code in the Form_Closing event to store application
> parameters and then I have code in the Form_Closed event
> that calls Application.Exit().

> I can step through the code in the MenuItem_Click event
> and see that the Me.Close() method is called but niether
> event method seems to be called and the application never
> exits.  Any clues as to why?



Mon, 07 Feb 2005 23:41:11 GMT  
 Form.Close method does not fire Form_Closing or Form_Closed events
I have created a test form, and added code as you described, but it works
fine. I think maybe you can create a new form to test it, and if it works
fine, compare the code in the old form with that of the new form to see
where the problem is.

David Yuan
This posting is provided "AS IS" with no warranties, and confers no rights.
"Got .Net?  http://www.gotdotnet.com".  



Tue, 08 Feb 2005 18:36:09 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Textbox validating event fires when closing a form.

2. What event fires when you close a form?

3. click event not firing if lost_focus is firing first

4. Event does not fire after showing a form

5. Form events not firing in public folder

6. Form's validate does not fire usercontrol(inside textbox) validating event

7. FORM Instances not firing activated event

8. MouseMove event not fired for forms with IsMdiContainer = true

9. Form's Actived event not firing...

10. KeyDown event not firing for form with KeyPreview = True

11. KeyDown/Up events not firing even if child form appears to have focus

12. Form's KeyPress event not firing - WHY???

 

 
Powered by phpBB® Forum Software