Hello I am new to programming, and I am getting stuck on getting it so if I press a button it adds 100 to an int called xAxis and draws a new rectangle on that xAxis.
int xAxisRec = 100;
public void Form1_Paint(object sender, PaintEventArgs pe)
{
Graphics g = pe.Graphics;
Pen blackPen = new Pen(Color.Black, 3);
g.DrawRectangle(blackPen, xAxisRec, 100, 100, 100);
}
public void plusRec_Click(object sender, EventArgs e)
{
xAxisRec += 100;
Form1_Paint(sender, pe);
}
The problem I am having is when I run this code I get the error message "The name 'pe' does not exist in the current context" and I don't know how to fix this, the error is occurring on this line
Form1_Paint(sender, pe);
Its probably a silly mistake but I just don't know what I have done wrong, thank you for taking time to read this.