I am struggling with getting the graphic to be redrawn with the invalidate method when the form goes the screen the graphic isn't redrawn i have tried to create an image from the graphics for it to been redrawn with the invalidate method but it doesn't work could somebody help edit the code for and do it in simple terms as i am still a beginner thanks would be much appreciated
private void squareButton_Click(object sender, EventArgs e)
{
// Declaring a new graphics object has been assigned null
Graphics objGraphics = null;
// This will create the picture graphics to be drawn in the picturebox
objGraphics = PictureBox1.CreateGraphics();
// This will redraw the picture box with a fill chosen after the systemcolors
objGraphics.Clear(SystemColors.ControlDark);
// This will draw the rectangle with a red pen 10,10 represent position and 50,50 reprsent the width and height
objGraphics.DrawRectangle(Pens.Red, 10, 10, 50, 50);
// This will draw the rectangle
objGraphics.Dispose();
Bitmap imgbit = (Bitmap)Picturebox.Image;
Graphics.FromImage(imgbit);
picturebox.invalidate();
// This is not redrawing the graphic it just shows a blank form
}