2012-07-21 55 views
1

我想绘制一个面板绘图每600毫秒600点。当我使用Graphics对象来绘制它时,只需绘制一个椭圆,屏幕就会闪烁!我怎样才能有效地绘制这样的图表而不闪烁?!如何以.Net形式绘制剧情图而不闪烁?

+0

[Double Buffering when not OnPaint()in drawing:why why not it work?](http://stackoverflow.com/questions/3113190/double-buffering-when-not-drawing-in- OnPaint中 - 为什么 - 犯规 - 这工作) – 2012-07-21 12:31:20

回答

0

一个简单的方法来解决这个问题是打开双缓冲。你的表单有一个双缓冲属性,你可以设置为true。

或者有时您可以在控件上进行操作,如果它支持的话。

例如

public class BufferedPanel : Panel { 
    public BufferedPanel() { 
    this.DoubleBuffered = true; 
    this.ResizeRedraw = true; 
    } 
} 

然后确保你使用控制的实际油漆事件:

class MyForm : Form 
{ 
    public MyForm() 
    { 
     InitializeComponent(); 
     this.DoubleBuffered = true; 
    } 
} 
0

面板的双缓冲需要通过继承开启

public Form1() { 
    InitializeComponent(); 
    bufferedPanel1.Paint += bufferedPanel1_Paint; 
} 

private void bufferedPanel1_Paint(object sender, PaintEventArgs e) { 
    e.Graphics.DrawSomething(...); 
} 
使用 CreateGraphics()为避免

那只是一个临时图纸。