C# winform 프로젝트에 문제가 있습니다.프로젝트의 버튼으로 사각형이 삭제됩니까?
나는 사각형을 그릴 기능을 가지고 :
내 프로젝트에서public void DrawingSquares(int x, int y)
{
System.Drawing.Graphics graphicsObj;
graphicsObj = this.CreateGraphics();
Pen myPen = new Pen(System.Drawing.Color.Black, 5);
Rectangle myRectangle = new Rectangle(x, y, 100, 100);
graphicsObj.DrawRectangle(myPen, myRectangle);
}
private void button1_Click(object sender, EventArgs e)
{
z = Convert.ToInt16(textBox1.Text)-1;
k = Convert.ToInt16(textBox2.Text)-1;
DrawAllSquares();
}
private void DrawAllSquares()
{
int tempy = y;
for (int i = 0; i < z; i++)
{
DrawingSquares(x, y);
for (int j = 0; j < k - 1; j++)
{
tempy += 50;
DrawingSquares(x, tempy);
}
x += 50;
tempy = y;
}
}
, 나는 런타임에 양식 주위 버튼을 이동하는 데 사용하는 기능을 가지고 있지만 버튼에 이동할 때 도면 도면이다 삭제됨
그림을 영구적으로 만들려면 어떻게해야합니까?
이 메서드를 호출 할 때 – VibeeshanRC