2010-12-15 76 views
0

我有一个picturebox,我可以加载一个图像到它的.backgroundimage函数,现在我有一个按钮,它是假设清除它,但没有。我曾尝试使用此代码: secondcapturebox.Dispose(); 但仍然图像是在picturebox。 请帮帮忙,清除c中的Picturebox.backgroundimage#

感谢

+0

你选错答案。不要绕过Dispose(),因为它在你尝试时不起作用。 – 2010-12-15 21:08:54

回答

1

你试过......

secondcapturebox.BackgroundImage = null; 
3

你必须将其设置为null。就像这样:

private void button1_Click(object sender, EventArgs e) { 
     if (pictureBox1.BackgroundImage != null) { 
      pictureBox1.BackgroundImage.Dispose(); 
      pictureBox1.BackgroundImage = null; 
     } 
    } 
0
pictureBox1.Image = null; 
pictureBox1.Invalidate(); 
pictureBox1.BringToFront(); 

pictureBox1.BackgroundImage = null; 
+1

欢迎来到StackOverflow!你的答案可以从这个代码解决这个问题的时候得到一些解释。 – 2016-06-27 08:54:34