Close windows when users

Does anyone have an idea to write code, if the user clicks the external form of the window, does the form automatically close? Ie, I had two forms, when I show form2, and then I click it, form 2 will be closed.

+2
source share
2 answers

Does it help? Try the first two solutions, one of which should work for you.

Winforms: closing a modal dialog when pressed outside of a dialog

+4
source

You can just use the built-in LostFocus event for a form like this

 Private Sub Form1_LostFocus(ByVal sender As Object, ByVal e As EventArgs) _ Handles Me.LostFocus Me.Close() End Sub 
+1
source

All Articles