I always find it so amazing how people don’t or won’t bother to spend even five minutes using a search engine like Google to find out about how to do something and instead spend more time posting a question on Yahoo! Answers.
We simply add e.Cancel = true to the Form’s Closing Event, there are two simple examples below.
Closing a Form in C#.NET goes like this:
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
e.Cancel = true
Closing a Form in VB.NET goes like this:
Private Sub Form1_Closing(ByVal sender As Object, ByVal e AsSystem.ComponentModel.CancelEventArgs)
e.Cancel = True
Author: Brian Cline