2010-12-15 90 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