Hi,
I'm trying to handle form closing, so I've created the code below.
The aim was I want to be able to control when a user clicks on the Red X button, which it does, but in my form I also have a 'Save' Button (btnSave). I don't want the MessageBox to show if the 'Save' button is clicked.
I'm not sure how to go about achieving this, any pointers would be great.
I'm trying to handle form closing, so I've created the code below.
VB.NET:
Private Sub frmConfig_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If MessageBox.Show("Are you sure you want to exit?", "App Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
e.Cancel = False
frmMain.Show()
myWriter.Close()
Exit Sub
Else
e.Cancel = True
End If
End Sub
The aim was I want to be able to control when a user clicks on the Red X button, which it does, but in my form I also have a 'Save' Button (btnSave). I don't want the MessageBox to show if the 'Save' button is clicked.
I'm not sure how to go about achieving this, any pointers would be great.