Son_Of_Diablo
Son_Of_Diablo

Reputation: 99

Binding Form Closing event in class

Hello I'm trying to make a class that can handle the form closing event for my winForm

I have figured out how to work the event handlers, like this for a ContextMenuStrip items click event:

mnuItemShow.Click += new EventHandler(mnuItemShow_Click);
private void mnuItemShow_Click(object sender, EventArgs e)
    {

    }

But I can't figure out how to bind the Form Closing event..

I have tried it like this:

this.form.FormClosing += new EventHandler(closing);
private override void closing(EventArgs e)
    {

    }

But I get this error message:

No overload for 'closing' matches delegate 'System.EventHandler'

Upvotes: 0

Views: 1833

Answers (1)

Hardik Gondalia
Hardik Gondalia

Reputation: 3717

it should be like this:

private void closing(object sender, FormClosingEventArgs e)
{

}

and you have to add handler like below

 frm.FormClosing += new FormClosingEventHandler();

Upvotes: 0

Related Questions