Hello Everyone,
I am writing a Windows Mobile 5.0 application using VS 2..8 in VB.NET.
When someone clicks the "Exit" menu option, which generates a
button_click() event, I find it easy to display an "Are you sure?"
MessgeBox before the application closes. That way, if they
accidentally selected exit, they have a chance to back out. But I also
want to catch the _closing() event on the form in case the user clicks
the application close X on the top of the application. When I use the
following code, it doesn't do anything at all:
Private Sub MainForm_Closin g(ByVal sender As System.Object, ByVal e
As _
System.Componen tModel.CancelEv entArgs) Handles
MyBase.Closing
Dim rs As Integer
rs = MessageBox.Show ("Are you sure you want to exit?",
"Confirm Exit", MessageBoxButto ns.OKCancel,
MessageBoxIcon. Exclamation, MessageBoxDefau ltButton.Button 1)
If (rs = vbOK) Then
Application.Exi t()
Else
Return
End If
End Sub
Am I doing this wrong? How can I best deal with this event? Is it even
possible?
Thanks!
Anthony
I am writing a Windows Mobile 5.0 application using VS 2..8 in VB.NET.
When someone clicks the "Exit" menu option, which generates a
button_click() event, I find it easy to display an "Are you sure?"
MessgeBox before the application closes. That way, if they
accidentally selected exit, they have a chance to back out. But I also
want to catch the _closing() event on the form in case the user clicks
the application close X on the top of the application. When I use the
following code, it doesn't do anything at all:
Private Sub MainForm_Closin g(ByVal sender As System.Object, ByVal e
As _
System.Componen tModel.CancelEv entArgs) Handles
MyBase.Closing
Dim rs As Integer
rs = MessageBox.Show ("Are you sure you want to exit?",
"Confirm Exit", MessageBoxButto ns.OKCancel,
MessageBoxIcon. Exclamation, MessageBoxDefau ltButton.Button 1)
If (rs = vbOK) Then
Application.Exi t()
Else
Return
End If
End Sub
Am I doing this wrong? How can I best deal with this event? Is it even
possible?
Thanks!
Anthony
Comment