2011-04-05 73 views
0

我有問題,形成應用我的問題是 我需要寫如何在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 

請幫我提前 感謝

+2

此錯誤消息似乎與您的方法無關。 – 2011-04-05 03:43:28

回答

2

這通常是因爲你已經設法讓IDE生成一個窗體加載事件HANDL呃(通過雙擊表單),並刪除了該方法而不刪除設計器生成的代碼以將該方法與事件關聯起來。

如果你去Form1.Designer.cs你應該看到一行看起來像這樣:

this.Load += new System.EventHandler(this.Form1_Load); 

刪除此行。

+2

而不是從生成的代碼中刪除它,將窗體上的'Load'事件重置爲默認(空)會更合適。 – 2011-04-05 04:00:14

+0

感謝它的工作 – 2011-04-05 04:07:14

+0

@ user691235我認爲你應該接受這個答案,如果它解決了你的問題。 – jfs 2011-04-05 04:50:16

1

通過form1的designer.cs檢查,必須給出form1.load的定義刪除,然後再次創建form1的加載事件。此外,問題出在你的設計師身上。檢查它將工作

1

我的猜測是,你在Form1的設計器中雙擊到代碼,它會自動生成一個Form1_Load方法來響應form1的Load事件。此後一段時間,您可能已刪除此代碼。 Form1的設計者仍然有對該事件處理程序的引用。