I want to paint a plot diagram in a panel with 600 points per each 100 milliseconds. When I do it using Graphics object and simply draw an ellipse, the screen flashes! How can I draw such a diagram efficiently and without flashing?!
Asked
Active
Viewed 335 times
2 Answers
0
An easy way to stop this is to turn double buffering on. Your form has a double buffered property which you can set to true.
Or sometimes you can do it on the control if it supports it.
e.g.
class MyForm : Form
{
public MyForm()
{
InitializeComponent();
this.DoubleBuffered = true;
}
}

IntelOrca
- 108
- 2
- 8
0
The panel's double buffering needs to be turned on via inheritance:
public class BufferedPanel : Panel {
public BufferedPanel() {
this.DoubleBuffered = true;
this.ResizeRedraw = true;
}
}
Then make sure you use the actual paint event of the control:
public Form1() {
InitializeComponent();
bufferedPanel1.Paint += bufferedPanel1_Paint;
}
private void bufferedPanel1_Paint(object sender, PaintEventArgs e) {
e.Graphics.DrawSomething(...);
}
Avoid using CreateGraphics()
as that is only a temporary drawing.

LarsTech
- 80,625
- 14
- 153
- 225