Event handlers in Visual Studio

c#, events, handler

Solution

There is a `Form.Designer.cs` file that hooks up the events for each individual form (each form has it's own designer file).

Open that and you'll find lines like:

button1.Click += button1_Click;

..etc.

As below:

Problem

When I try to create an event handler eg. button click in c#, if I write the code manually in code behind class, the event handler won't be called; Whereas if I double click the button on the form and the VS auto generates the event, it will work perfectly. What is the reason behind this behavior?

Original source