If you draw images in the form, no matter whether the dual cache is used or not, you will see that the images will continuously flash during update, the solution is to add the following three lines of code to the constructor of the form:
Add the following lines to the constructor:
Setstyle (controlstyles. userpaint,True );
Setstyle (controlstyles. allpaintinginwmpaint,True );//Do not erase background.
Setstyle (controlstyles. doublebuffer,True );//Double Buffering
Parameter description:
Userpaint
IfTrue, the control will be drawn by itself, rather than by the operating system. This style applies only to derived fromControl.
Allpaintinginwmpaint
IfTrue, the control will ignoreWm_erasebkgndWindow message to reduce flickering. Only whenUserpaintBitTrueThe style must be applied.
Doublebuffer
IfTrue, it is drawn in the buffer. After the result is finished, it is output to the screen. The dual buffer can prevent flickering caused by control re-painting. To fully enable double buffering, you must alsoUserpaintAndAllpaintinginwmpaintSet the style bitTrue.
References:
How to solve the problem of animation flash in CSHARP?
Http://search.csdn.net/Expert/topic/1488/1488888.xml
C # Implementation of Double Cache plotting.
Http://blog.joycode.com/ghj/archive/2004/01/03/10543.aspx
The above is not a drawing on the form. You need to write a control yourself and add the above three lines of code to the constructor of the control.