Skip to content

Instantly share code, notes, and snippets.

@tamago324
Created November 14, 2017 09:30
Show Gist options
  • Save tamago324/1e66ec433b828dc26d6b3a33db89df9d to your computer and use it in GitHub Desktop.
Save tamago324/1e66ec433b828dc26d6b3a33db89df9d to your computer and use it in GitHub Desktop.
ボタンで閉じられる以外の場合、ダイアログを表示して、閉じさせないようにする
Public Class BaseForm
''' <summary>ボタンで閉じられたかどうか</summary>
Protected isClosedBtn As Boolean = False
Private Sub BaseForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
isClosedBtn = False
End Sub
Private Sub BaseForm_Closed(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If Not isClosedBtn Then
MsgBox("ボタンで閉じて!")
e.Cancel = True
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
isClosedBtn = True
Me.Close()
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment