如何清除在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)];
} 发布于 2011-05-02 18:48:10
将Image property设置为null就可以了。它将清除图片框中当前显示的任何图像。确保您编写的代码完全像这样:
picBox.Image = null;发布于 2011-05-02 18:57:36
正如其他人所说,将Image属性设置为null应该是可行的。
如果没有,这可能意味着您使用了InitialImage属性来显示图像。如果确实是这样,请尝试将该属性设置为null:
pictBox.InitialImage = null;发布于 2014-07-15 20:09:06
if (pictureBox1.Image != null)
{
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
}https://stackoverflow.com/questions/5856196
复制相似问题