I am currently working with a pictureBox. I am having difficulties drawing a grid over the picture box that is approximately the size of 2 x 2 squares. Now the code below is only giving me a line drawn across. How can I proplery draw a full grid on top of the pictureBox?
CODE:
private Graphics g1;
public Form1()
{
InitializeComponent();
pictureBox1.Image = new Bitmap(500, 500);
g1 = Graphics.FromImage(this.pictureBox1.Image);
Pen gridPen = new Pen(Color.Black, 2);
g1.DrawLine(gridPen, 0, 0, 100, 100);
}
This what I would like to accomplish:

I found this question:
Efficiently draw a grid in Windows Forms
Here is the gist of it:
Customize accordingly