Reputation: 1739
Using c# windows forms.
I'm using the backgroundImage of a panel to draw. I want to remove all drawings from the panel.
How can I simply do this?
Upvotes: 3
Views: 13845
Reputation: 466
these both codes works fine.
this.myPanel.BackgroundImage = null;
or
this.myPanel.BackgroundImage = base.BackgroundImage;
Upvotes: 1
Reputation: 90
You can not use panel.backgroundImage.Dispose because there is not Dispose method of a Control.BackgroundImage property. You can use
panel.BackgroundImage = null;
to remove all the contents of a panel.
Make it clear that, The Dispose method is available only for controls, leaves the control in an unusable state. After calling Dispose, you must release all references to the control so the garbage collector can reclaim the memory that the control was occupying.
Upvotes: 3
Reputation: 7668
If you set a BackgroudImage, then use
this.myPanel.BackgroundImage = null;
to remove it...
Upvotes: 3