2011-01-12 77 views

回答

2

同原則作爲leppie的答案。除了你需要設置ImageBox.Image屬性來代替:

myImageBox.Image = null; 


這工作,因爲下面的代碼(從Hans's answer to your previous question摘錄):

protected override void OnPaint(PaintEventArgs e) { 
    e.Graphics.TranslateTransform(this.AutoScrollPosition.X, this.AutoScrollPosition.Y); 
    if (mImage != null) e.Graphics.DrawImage(mImage, 0, 0); 
    base.OnPaint(e); 
} 

當控件的Image屬性設置爲null,屬性設置器強制控件重新繪製自己(this.Invalidate();)。重新繪製時,不會繪製圖像,因爲負責繪製控件的OnPaint方法會在繪製之前驗證mImage != null

+0

完美。謝謝。 – 2011-01-12 10:53:21

1

下面應該工作:

Form.BackgroundImage = null; 
+0

嗨,不幸的是這不工作,因爲位圖不直接加載到窗體。請參閱我上面的編輯。謝謝。 – 2011-01-12 10:32:49

相關問題