Form.Closing not listed as event for form?

c#, events, forms, winforms

Solution

It's called `FormClosing` not `Closing`. You can add the event by going to the properties window and clicking on the "Events" button then double-clicking on the "FormClosing" item:

You're almost there with what you have. What you're missing is the code-behind that wires up the event to your handler, which is automatically generated for you when you follow the above procedure. Here's what it looks like in the `InitializeComponent` method in the "Form1.Designer.cs" file (click the "Show All Files" button on the top of the Solution Explorer):

this.FormClosing += 
    new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);

Problem

I'm using Visual Studio 2010; usually when I want to add events other than mouse clicks I go to to the events tab and find the event, click it, and it takes me to that spot in code. However, I can't find any for the `Closing` event of the form. I've tried manually adding it in but I think there's more behind the scenes stuff that VS is taking care of: ``` private void Form1_FormClosing(object sender, FormClosingEventArgs e) { } ``` What's the most effective way for having everything 'written' for the `FormClosing` event? Or how do I enter it all manually if I must? This is form WinForms.

Original source