If OnPaint isn't called, the form isn't painted though, resulting in a blank white areas if the form is invalidated. The only way to fix it is to draw whatever it is you want on it every time the form is painted. You could use double buffering to draw it to an image, then draw that image every time (assuming you have control over the Graphics object used to draw).
well it doesnt matter if it doesn't repaint as the form never goes out of sight.
Basically i have a card game, the onPaint event paints all the players cards face down, however i would like a button that whn pressed down shows they cards face up and when they release the button they return to face down.
Problem is when the show button is pressed it paints the relevant cards face up but then causes the onPaint which prints the cards face down again!
Why not just add a boolean variable that defines whether the cards should be drawn face up or face down? Just invert it when the button is pressed and invalidate the form (using Invalidate()) to cause the form to be repainted appropriately.
You can get rid of the flickering by using a double buffering technique
(Effectively painting to a buffer in memory then transferring this to what's on screen)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.