我该如何在picturebox上清除绘制的图像?以下方法对我不起作用:
pictbox.Image = null;
pictbox.Invalidate();
请帮忙。
编辑
private void pictbox_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
vl.Draw(g, ref tran.realListForInsert);
}
public void Draw(Graphics g, ref List<double> arr)
{
g.DrawRectangle(new Pen(Brushes.Red, 3), nodeArr[Convert.ToInt32(templstName)].pict.Location.X, nodeArr[Convert.ToInt32(templstName)].pict.Location.Y, 25, 25);
g.DrawRectangle(new Pen(Brushes.Green, 3), nodeArr[Convert.ToInt32(templstArgName)].pict.Location.X, nodeArr[Convert.ToInt32(templstArgName)].pict.Location.Y, 25, 25);
nodeArr[Convert.ToInt32(templstName)].text.Text = arr[Convert.ToInt32(templstArgName)].ToString();
arr[Convert.ToInt32(templstName)] = arr[Convert.ToInt32(templstArgName)];
}
InitialImage
属性保存的是在实际图像加载(通常是通过ImageLocation
属性)期间显示的图像。您可以将其视为临时占位符。我同意您在@V4Vendetta答案中的评论,似乎问题提问者的PictureBox
实际上并不包含图像,但看起来他确实想要删除占位符,这可能是不可能的。 - Frédéric Hamidi