c# - 'johny.Form 1' does not contain a definition for ' Form1_Load'

标签 c# event-handling

我有这个错误:

Error 1 'johny.Form1' does not contain a definition for 'Form1_Load' and no extension method 'Form1_Load' accepting a first argument of type 'johny.Form1' could be found (are you missing a using directive or an assembly reference?)

这是我从表单设计者那里得到的代码:

    // 
    // Form1
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(456, 411);
    this.Controls.Add(this.l6);
    this.Controls.Add(this.label1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.ResumeLayout(false);
    this.PerformLayout();

错误来自这一行:

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

最佳答案

错误告诉您您的 Form1 类中没有 Form1_Load 方法,而您正在尝试使用一个方法。

如果您在首次加载表单时不需要进行任何初始化,请删除该行,或者确保您有初始化(符合 EventHandler 委托(delegate)的签名)。

关于c# - 'johny.Form 1' does not contain a definition for ' Form1_Load',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14172404/

相关文章:

C# WPF : Place UserControl in DataGridRow

c# - Akka .NET PipeTo() 和ContinueWith()

c# - EventArgs 类和 event 关键字之间是否存在特殊关联?

jquery - 在 jQuery 中,每次 DOM 更改时如何调用函数?

java - ACTION_UP 不起作用,但 ACTION_DOWN 工作正常

c# - 从 MySQL 数据库获取图像 - C#

c# - 在 Entity Framework 中更新数据库而不迁移

c# - 使用事件处理程序刷新所有 DataGrid

C# 舍入 MidpointRounding.ToEven 与 MidpointRounding.AwayFromZero

javascript - 如何在 keyCode 为只读的浏览器中聚焦下一个可聚焦字段?