本文介绍了退出事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用Sub Main和ApplicationContext,是否可以检测到何时退出应用程序?我还没找到任何东西,所以尽管我会询问所有人.

谢谢!

Is there a way to detect when an application exits if I am using Sub Main and ApplicationContext? I haven''t been able to find anything yet, so I though I would ask y''all.

Thanks!

推荐答案

Private Sub Form1_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
      ' Determine if text has changed in the textbox by comparing to original text.
      If textBox1.Text <> strMyOriginalText Then
         ' Display a MsgBox asking the user to save changes or abort.
         If MessageBox.Show("Do you want to save changes to your text?", "My Application", MessageBoxButtons.YesNo) = DialogResult.Yes Then
            ' Cancel the Closing event from closing the form.
            e.Cancel = True
         End If ' Call method to save file...
      End If
   End Sub 'Form1_Closing
End Class 'Form1


这篇关于退出事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 08:21