I wish in my code to handle the case when the red X at the upper right of the form is clicked. To this end I consulted this and created an event handler thus:-
Private Sub DoFoo (sender As System.Object, e As System.EventArgs) _
Handles Me.FormClosing
' Do things
End Sub
but I have found (from setting breakpoints) that on certain forms this event handler is not invoked when the red X is clicked, whereas on others it is. The forms are all of type System.Windows.Forms.Form but naturally are different in most respects. Does anyone know what might be causing this and what to do about it?
Edit
In answer to Vitor's question, the form that isn't working is created thus:-
If my_form Is Nothing Then
my_form = New MyForm(parameters)
my_form.Title = "Contour Plot Options"
Else
my_form.BringToFront
End If
my_form.Show
Those that are behaving as expected are created like this:-
If my_working_form Is Nothing Then
my_working_form = New MyWorkingForm
End If
my_working_form.Show
I can't see any Visible
property to set or clear anywhere.