您好我试图创建一个可以处理winForm的表单结束事件的类
我已经找到了如何处理事件处理程序,就像这样一个ContextMenuStrip项目点击事件:
mnuItemShow.Click += new EventHandler(mnuItemShow_Click);
private void mnuItemShow_Click(object sender, EventArgs e)
{
}
但我无法弄清楚如何绑定Form Closing事件..
我试过这样的话:
this.form.FormClosing += new EventHandler(closing);
private override void closing(EventArgs e)
{
}
但我收到此错误消息:
没有超负荷关闭'匹配委托' System.EventHandler'
答案 0 :(得分:1)
这有效:
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing);
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
}
答案 1 :(得分:0)
它应该是这样的:
private void closing(object sender, FormClosingEventArgs e)
{
}
你必须添加如下的处理程序
frm.FormClosing += new FormClosingEventHandler();