-1

In Program.cs, Argument EventArgs changed to FormClosingEventArgs

private void Exit_Click(object sender, FormClosingEventArgs e) {   }

In Program.Designer.cs, Change in Program.cs lead to an error at Line.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 an error CS0123: No overload for 'Exit_Click' matches delegate 'EventHandler'.

Everytime when I start debug this will be show to me, I using Visual Studio 2017,What's is the problem overthere.....?

Aryan Firouzian
  • 1,940
  • 5
  • 27
  • 41
CosMik
  • 51
  • 4

1 Answers1

1

It's because of Click handler of a System.Windows.Forms.Control does not take argument of type FormClosingEventArgs, rather it takes EventArgs which needs to be passed like this

private void Exit_Click(object sender, EventArgs e) {   }

In simpler words, it's like assigning a string value to an int variable

For more information see this - https://msdn.microsoft.com/en-us/library/system.windows.forms.control.click(v=vs.110).aspx

Ipsit Gaur
  • 2,872
  • 1
  • 23
  • 38