閉じるボタンの処理@VB.Net
閉じるボタンの処理です。
画面右上の「×」を押された時の処理です。
クロージングのイベントをハンドルします。
終了条件を決めて、合致しない場合は、
e.Cancel = Trueとすれば画面は終了しません。
下記では、確認ダイアログを表示して、
判断を行い画面を閉じています。
Public Class Form1
'クロージングイベント
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If MessageBox.Show("終了しますか?", "終了確認ダイアログ", MessageBoxButtons.YesNo) = DialogResult.No Then
e.Cancel = True
End If
End Sub
End Class
|
|