I have two very simple methods in my VB.Net, VS2012 project:
A button click event:
Private Sub bExit_Click(sender As Object, e As EventArgs) Handles bExit.Click
DialogResult = Windows.Forms.DialogResult.OK
A form closing event:
Private Sub frmEditMKL_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If e.CloseReason = 3 Then
MessageBox.Show(Me, "Please use the 'Exit' button", "Edit MKL", MessageBoxButtons.OK, MessageBoxIcon.Information)
e.Cancel = True
If I open the form, and click the Exit Button, e.CloseReason = 0 and the form closes without incident.
If I open the form, and hit the X, e.CloseReason = 3 and the user is told to click the Exit button; the form does not close.
All good so far.
But, if, after I have hit the X, gotten the message, and then click on the Exit button e.CloseReason is still 3 and the form won't close.
Any ideas how I can resolve this or what is going on?