user235599
user235599

Reputation: 1

How to keep my panel refreshed... it disappears

In C# (GDI+) when I draw something on the panel using the class Graphics... when I pass another window forground (on the panel) everything I have drawn disapears...!!

How to fix it ?

Thank you...

Upvotes: 0

Views: 1136

Answers (1)

albertein
albertein

Reputation: 27140

You need to paint everything on the Paint event.

Basically nothing painted is persistent because the windows needs to redraw itself again after it's overlaped, minimized, etc. So, if you want to paint something you need to do it on the Paint event, basically repainting it every time is needed.

If you only need to paint your stuff after the user clicks on a button, just put your drawing code on the paint event but don't do anything if some flag is not set, your button will only need to set the flag and call the Invalidate method of your panel to force it to redraw itself running your code on the process.

Upvotes: 5

Related Questions