To flight flashing, you need to use double buffering. For a form, please use
System.Windows.Forms.From.DoubleBuffered
property,
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx[
^].
It can practically eliminate flashing.
If you have flashing with some other control, you need to sub-class such control in order to get access to a protected method
System.Windows.Forms.Control.SetStyle
. You would need to add the styles
ControlStyles.OptimizedDoubleBuffer
|
ControlStyles.AllPaintingInWmPaint
.
Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setstyle.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.controlstyles.aspx[
^].
You can use this method with the
Form
as well as it is
Control
.
If you code is slow, you must be doing something wrong (double buffering can only made it a little bit slower), but it's hard to say anything without some code sample to manifest this problem.
—SA