I have this bit of code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class vars
{
public static int x = 250;
public static int y = 250;
}
private void button1_Click(object sender, EventArgs e)
{
button1.Visible = false;
Pen main = new Pen(Color.Black);
this.Graphics.DrawRectangle(main, vars.x, vars.y, 2, 2);
while (true)
{
}
}
}
}
But i keep getting an annoying error (No overload for ‘button1_Click’ matches delegate ‘System.EventHandler’) that I don’t know how to approach. Ive been searching online and trouble shooting for a while, and have not found any answers. Any suggestions would be appreciated.
Delete the
PaintEventArgs gpart of your code. The method that is attached to an event must match the “pattern” for the event.Declare the vars outside of your own class, unless you will need them outside of Form1. Its just unnecessary.
That should work!