1
我想繪製一個面板繪圖每600毫秒600點。當我使用Graphics對象來繪製它時,只需繪製一個橢圓,屏幕就會閃爍!我怎樣纔能有效地繪製這樣的圖表而不閃爍?!如何以.Net形式繪製劇情圖而不閃爍?
我想繪製一個面板繪圖每600毫秒600點。當我使用Graphics對象來繪製它時,只需繪製一個橢圓,屏幕就會閃爍!我怎樣纔能有效地繪製這樣的圖表而不閃爍?!如何以.Net形式繪製劇情圖而不閃爍?
一個簡單的方法來解決這個問題是打開雙緩衝。你的表單有一個雙緩衝屬性,你可以設置爲true。
或者有時您可以在控件上進行操作,如果它支持的話。
例如
public class BufferedPanel : Panel {
public BufferedPanel() {
this.DoubleBuffered = true;
this.ResizeRedraw = true;
}
}
然後確保你使用控制的實際油漆事件:
class MyForm : Form
{
public MyForm()
{
InitializeComponent();
this.DoubleBuffered = true;
}
}
面板的雙緩衝需要通過繼承開啓
public Form1() {
InitializeComponent();
bufferedPanel1.Paint += bufferedPanel1_Paint;
}
private void bufferedPanel1_Paint(object sender, PaintEventArgs e) {
e.Graphics.DrawSomething(...);
}
使用
CreateGraphics()
爲避免
那只是一個臨時圖紙。
[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