Heres a sample to check if the user clicks on 'X' in the right top of the window, instead of save and close button
' declare the variable in the form code behind
Private confirmClose As Boolean
Private Sub btnSaveAndClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveAndClose.Click
confirmClose = True
Me.Close()
End Sub
Private Sub DemoForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not confirmClose Then
' means the he has not clicked on trial button, but X
e.Cancel = True
' this will not allow the window to close
' add msg box to show that user has to click of
' save and close button, and cannot use 'X' to close the application
End If
End Sub
No comments:
Post a Comment