【问题标题】:How to resolve system event handler error in C#?如何解决 C# 中的系统事件处理程序错误?
【发布时间】:2016-04-21 02:54:19
【问题描述】:

我正在尝试清除 C# 中的系统事件处理程序。

我收到以下错误:

“错误 1 ​​'Initialize_Click' 没有重载匹配委托 'System.EventHandler' D:\Tool\Macro\Testmac\Testmac\Form1.Designer.cs 72 38 Testmac " 当我更改我的函数名称和参数对象时。我收到这个错误。请指导我。

这是我的代码:

OLD code:

private void button1_Click(object sender, EventArgs e)
{
}


New CODE:

private void Initialize(string filename, string tablename)
        {
            string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Mode=ReadWrite;Extended Properties=\"Excel 8.0;HDR=NO\"";
            string fieldstring = "(ID int, Field1 char(255), Field2 char(255))";

        }

        

请指导我

【问题讨论】:

    标签: c# asp.net c#-4.0 c#-3.0


    【解决方案1】:

    System.EventHandler 委托的类型为

    public delegate void EventHandler(object sender, EventArgs e)
    

    所以这个错误意味着你的代码中有some_handler += this.Initialize之类的东西,你应该将处理程序定义为private void handler(object sender, EventArgs e),并在其中调用Initialize函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-14
      • 2013-11-22
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      • 2011-09-30
      相关资源
      最近更新 更多