我的 C# Windows-Forms 项目有问题。我正在尝试绘制一个正方形,并且想在图片框中显示该正方形。我怎样才能做到这一点?
这是我绘制正方形的函数:
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);
}