title: how to draw a square in to a PictureBox?
body: <p>I have a problem with my C# Windows-Forms project. I am trying to draw a square and I want to display the square inside a picture-box. How can I do that?</p>
  
  <p>This is my function for drawing the square:</p>
  
  <pre><code>public void DrawingSquares(int x, int y)//the function gets x and y to know where to print the square.
      {
          Graphics graphicsObj;
          graphicsObj = this.CreateGraphics();
          Pen myPen = new Pen(Color.Black, 5);
          Rectangle myRectangle = new Rectangle(x, y, 100, 100);
          graphicsObj.DrawRectangle(myPen, myRectangle);
      }
  </code></pre>