protected override void OnPaintBackground(PaintEventArgs pevent)
{
// do nothing
}
This blog is a depository for things I have found regarding VB.NET and C#.NET development (and other things I may need to remember). This blog is primarily for my own reference, but if the information I found is useful to others, then that is great. If others want to contribute with comments or other information, then that is great too.
Tuesday, July 12, 2011
Preventing Flicker with GDI+ drawing in C#
In C#, the OnPaintBackground method is called before the OnPaint event and it draws the background color for the entire view. If you are already drawing the background in the OnPaint event, then this process will cause flicker. You can override the OnPaintBackground and just do nothing in it to prevent the flicker:
Subscribe to:
Post Comments (Atom)
2 comments:
The easier way is to enable Double Buffer for your form/control.
Example:
class BufferedPanel : Panel
{
public BufferedPanel()
{
this.DoubleBuffered = true;
}
}
True in some cases, but in my case I am bliting the entire view on every OnPaint, so double buffer would be a waste of both resources and performance.
Post a Comment