Reputation: 1
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
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