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?
This is my function for drawing the square:
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);
}
this is my Form1.cs
you should have something simillar