【问题标题】:Binding Form Closing event in class在类中绑定表单关闭事件
【发布时间】:2014-09-09 19:11:49
【问题描述】:

您好,我正在尝试创建一个可以为我的 winForm 处理表单关闭事件的类

我已经弄清楚如何使用事件处理程序,例如 ContextMenuStrip 项目单击事件:

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

    }

但我不知道如何绑定表单关闭事件..

我试过这样:

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

    }

但我收到此错误消息:

“关闭”没有重载匹配委托“System.EventHandler”

【问题讨论】:

标签: c# winforms event-handling


【解决方案1】:

这行得通:

this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing);
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{

}

【讨论】:

    【解决方案2】:

    应该是这样的:

    private void closing(object sender, FormClosingEventArgs e)
    {
    
    }
    

    你必须像下面这样添加处理程序

     frm.FormClosing += new FormClosingEventHandler();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-12
      • 2015-10-01
      • 2014-06-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 2013-03-04
      相关资源
      最近更新 更多