I have been trying to teach myself c# through tutorials and this website and I didn't know how to make my "character" move using the arrow keys so I copied code from here hoping it would work and everything is fine until I run and then it throws me this error
Error 1 No overload for 'pictureBox1_Click' matches delegate 'System.EventHandler' c:\users\collin\documents\visual studio 2013\projects\my_rpg\my_rpg\form1.designer.cs 80 39 My_RPG
Here is the code I copied (I did change the name from whatever it was originally to pictureBox1 so that is correct"
public MainScreen()
{
InitializeComponent();
KeyDown += new KeyEventHandler(MainScreen_KeyDown);
if (characterCreated == false)
{
playGameBtn.ForeColor = Color.Gray;
}
}
private void pictureBox1_Click(object sender, KeyEventArgs e)
{
int x = pictureBox1.Location.X;
int y = pictureBox1.Location.Y;
if (e.KeyCode == Keys.Right)
{
x += 2;
}
else if (e.KeyCode == Keys.Left)
{
x -= 2;
}
else if (e.KeyCode == Keys.Up)
{
y += 2;
}
else if (e.KeyCode == Keys.Down)
{
y -= 2;
}
pictureBox1.Location = new System.Drawing.Point(x, y);
}
And then if I click on the error it sends me to this line of code that if I edit then it throws me errors
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);