我在Windows窗体应用程序中编写代码时遇到问题我的问题是 我需要写
private static void DownloadFiles(IEnumerable<string> filenames,
string uri, string localPath, string user, string password)
然而,当我写它时,我收到以下错误:
'WindowsFormsApplication10.Form1' does not contain a definition for 'Form1_Load' and no extension method 'Form1_Load' accepting a first argument of type 'WindowsFormsApplication10.Form1' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\WindowsFormsApplication10\WindowsFormsApplication10\Form1.Designer.cs
请帮帮我 提前致谢
答案 0 :(得分:2)
这通常是因为您已设法让IDE生成表单加载事件处理程序(通过双击表单),并删除了方法而不删除设计器生成的代码以将该方法与事件链接。 / p>
如果你转到Form1.Designer.cs
,你会看到一行如下:
this.Load += new System.EventHandler(this.Form1_Load);
删除此行。
答案 1 :(得分:1)
通过form1的designer.cs检查必须给出form1.load删除的定义并再次创建form1的load事件。此外,问题是只有你的设计师。检查一下它会起作用
答案 2 :(得分:1)
我的猜测是你在Form1的设计器中双击以获取代码,它会自动生成一个Form1_Load方法来响应form1的Load事件。在此之后的一段时间,您可能已删除此代码。 Form1的设计者仍然引用了该事件处理程序。