在Program.cs中,Argument EventArgs 更改为 FormClosingEventArgs
private void Exit_Click(object sender, FormClosingEventArgs e) { }
在Program.Designer.cs中,更改 Program.cs 会导致第9行出错
private void InitializeComponent()
{
this.Exit = new System.Windows.Forms.Button();
this.SuspendLayout();
this.Exit.Location = new System.Drawing.Point(839, 275);
this.Exit.Name = "Exit";
this.Exit.Size = new System.Drawing.Size(169, 112);
this.Exit.TabIndex = 0;
this.Exit.Text = "Exit";
this.Exit.UseVisualStyleBackColor = true;
this.Exit.Click += new System.EventHandler(this.Exit_Click); //ErrorPart
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1020, 399);
this.Controls.Add(this.Exit);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
Exisi错误CS0123:'Exit_Click'没有超载与委托'EventHandler'匹配。
每当我开始调试时,这将显示给我,我使用Visual Studio 2017,问题是什么?#/ p>
答案 0 :(得分:1)
由于Click
的{{1}}处理程序不接受System.Windows.Forms.Control
类型的参数,而是需要传递FormClosingEventArgs
这样的EventArgs
private void Exit_Click(object sender, EventArgs e) { }
简单来说,就像为
string
分配int
值一样 变量
有关详细信息,请参阅此内容 - https://msdn.microsoft.com/en-us/library/system.windows.forms.control.click(v=vs.110).aspx