控件重绘太慢
忽然觉得当窗体中的控件需要重绘的时候,控件都是一个一个刷出来的,效果很不好,即使只有一个控件要重绘,也能很明显的感觉出重绘前的空白,不知道有没有办法可以解决这个问题。
[解决办法]
[解决办法]
他肯定是说DoubleBuffered的属性没用。。。呵呵
其实你自己画到位图又能实现到什么程度呢?,别以为光把this给画进去了就行了,要屏蔽this的所有Child的Paint,然后将所有的Child的Paint画到你的位图上,同样,Child可能还有Child。。。
人家的DoubleBuffered是从Control类就有的,应该已经考虑这些问题了,估计设置的问题吧,去MSDN搜索一下OptimizedDoubleBuffer
这儿有双缓冲的例子
- C# code
// This example assumes the existence of a form called Form1.BufferedGraphicsContext currentContext;BufferedGraphics myBuffer;// Gets a reference to the current BufferedGraphicsContextcurrentContext = BufferedGraphicsManager.Current;// Creates a BufferedGraphics instance associated with Form1, and with // dimensions the same size as the drawing surface of Form1.myBuffer = currentContext.Allocate(Form1.CreateGraphics(), Form1.DisplayRectangle);