Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

panel clear everything

Tags:

c#

controls

panel

I would like to reset a panel to its initial state. For e.g., I set an image as background, I drew graphics on a part of the panel. I have to clear everything. How?

like image 448
y_zyx Avatar asked May 11 '11 03:05

y_zyx


3 Answers

You have to clear the panel first

panel1.Controls.Clear();

then call the initial form.

panel1.Controls.Add(orig_form);
like image 97
Ralph Calupas de Guzman Avatar answered Oct 08 '22 01:10

Ralph Calupas de Guzman


Use the following code to delete all graphics from the panel

panel1.Invalidate();

If there is something you need to add to panel's initial state then after you call invalidate you again have to set those things.

If the initial state of panels needs some graphics or data you can put that in panel's graphics event, so everytime invalidate is called your panel get the initial state with those items.

like image 40
AndroidLearner Avatar answered Oct 07 '22 23:10

AndroidLearner


Use the panel1.refresh(); command. It resets the panel to its initial state.

like image 38
Jakob Avatar answered Oct 08 '22 00:10

Jakob