How do I go about changing what happens when a user clicks the close (red X) button in a Windows Forms application (in C#)?
One thing these answers lack, and which newbies are probably looking for, is that while it's nice to have an event:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
// do something
}
It's not going to do anything at all unless you register the event. Put this in the class constructor:
this.FormClosing += Form1_FormClosing;