Q:

How to make a specific region from picture box as grid of a specific number of cells in C#

The following is the code to make a grid of 100 cells for a region of 500*500 of a picture box. This region start from x = 300 y = 200 and end in x = 800 y = 700. Each cell side equal to 50 pixel. 
//makes grid in picture box
        private void drawGrid()
        {
            int numOfCells = 100;
            int cellSize = 50;
            Pen p = new Pen(Color.Blue);

            for (int i = 0; i < numOfCells; i++)
            {
                // Vertical
                paper.DrawLine(p, i * cellSize, 200, i * cellSize, 700);
                // Horizontal
                paper.DrawLine(p, 300, i * cellSize, 800, i * cellSize);
            }
        }

I got additional lines outside the grid and I don't know how to remove them, kindly refer to the following snapshot in the following link to understand me more. 
snapshot(here)

A:

You are looping and drawing two lines for each cell. However, since you are drawing a square grid, you want to loop Math.Sqrt(numOfCells) + 1 times to draw 11 lines in this case to include the border.
You also want to offset the i*cellSize expressions by your x and y values.
So, paper.DrawLine(p, i * cellSize, 200, i * cellSize, 700); becomes paper.DrawLine(p, i * cellSize + 300, 200, i * cellSize + 300, 700); and a similar offset by 200 on the horizontal line.

