'button1_Click'匹配委托无过载



我不明白为什么会出现这个错误。。。有人能帮我吗?

    private void button1_Click(object sender, EventArgs e, string filePath)
    {
        OpenFileDialog of = new OpenFileDialog();
        of.ShowDialog();
        Filenametext.Text = of.FileName;
        //Create an instance for the openbox dialog
        //And opens the explorer to select the wanted file.
        {
            DataRow row;
            DataService m_WsData = new DataService();

            string XMLFileName = ConfigurationSettings.AppSettings["XMLPath"].ToString() + DateTime.Now.Ticks.ToString() + ".xml";
            FileStream fs = new FileStream(filePath, FileMode.Open);
            StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("ISO-8859-1"));
            {
                DataSet ds = m_WsData.GEDS();

                string line = "";
                int lineNo = 0;
                string lineStart = "";
                string lineEnd = "";
                string[] fileRow;
                {
                    line = sr.ReadLine();
                    if (line != null)
                    {
                        fileRow = line.Split(new Char[] { ';' });
                        if (lineNo == 0)
                        {
                            lineStart = fileRow[0];
                        }
                        if (fileRow[0] != "00" && fileRow[0] != "99")
                        {
                            row = ds.Tables["FuelFileData"].NewRow();
                            row["TransNo"] = fileRow[0];
                            row["CustomerNo"] = fileRow[1];
                            row["TruckNo"] = fileRow[2];
                            row["FuelDate"] = fileRow[3];
                            row["FuelTime"] = fileRow[4];
                            row["Place"] = fileRow[5];
                            row["FuelTypeNo"] = fileRow[6];
                            row["FuelDescription"] = fileRow[7];
                            row["DriverNo"] = fileRow[8];
                            row["Blank"] = fileRow[9];
                            row["TransType"] = fileRow[10];
                            row["Fuel"] = fileRow[11];
                            row["FuelCost"] = fileRow[12];
                            row["MileageFile"] = fileRow[13];
                            row["DrivenKm"] = fileRow[14];
                            row["AverageConsFile"] = fileRow[15];
                            //row["ImportedGuid"]=fileRow[16];

                        }
                        lineEnd = fileRow[0];
                        lineNo++;
                    }
                } while (line != null);
                lineStart = lineStart.Trim() + lineEnd.Trim();
                fs.Close();
                if (lineStart == "0099")
                {
                    ds.WriteXml(XMLFileName);
                    System.IO.File.Delete(XMLFileName);
                }
            }
        }
    }

原因

不能在事件处理程序方法上添加参数。Click事件定义为

public event RoutedEventHandler Click;

这意味着处理程序必须匹配作为的代表CCD_ 2

public delegate void RoutedEventHandler(Object sender, RoutedEventArgs e);

解决方案

删除string filePath参数并通过公共属性传递路径。

相关内容

  • 没有找到相关文章