Reputation: 60691
I have multiple forms in my VB.NET application. How do I make it so that any form I close will terminate the application?
Upvotes: 2
Views: 451
Reputation: 754525
The easiest way is to create a base class Form from which all of your Forms inherit. In that particular class you can override the OnClosed method and call Application.Exit to quit the program. Now the closing of any form in your application which derives from this Form, will cause the application to Exit
Public MustInherit Class MyForm
Inherits Form
Protected Overrides Sub OnClose(args As EventArgs)
Application.Exit()
End Sub
End Class
Upvotes: 3
Reputation: 37875
You could probably put your Application.Exit()
call in the OnClosed
method of the forms.
Upvotes: 3