Windows Compact 2013, C# and Double Buffering

时间:2015-11-12 11:12:17

标签: c# windows-ce doublebuffered

I'm using Win CE 13 to display some information on a fueling panel using the Windows.Forms library.

For example a Windows.Forms.Label object is used to display the current time and another to display the amount of pumped fluid. Now these labels' texts are assigned every 500ms which leads to a kind of annoying flickering every other second, especially if the label is rather big.

Unfortunately the Control.DoubleBuffered property isn't available on WinCE 2013 which was my only guess to solve the problem.

Maybe you can give some advice on how to avoid the flickering or at least reduce it to a minimum.

Greets P.W

1 个答案:

答案 0 :(得分:1)

参考Alan在这篇文章中的回答:https://stackoverflow.com/a/24294229/5546999为System.Windows.Forms.Label编写一个包装类并使用Alan提供的代码启用DoubleBuffering非常简单。 由于标签实际上只包含一个字符串作为信息,因此Graphics.DrawString方法绝对足够。由于它继承自System.Windows.Forms.ScrollableControl,因此包装类本身可以检索Font。 由于可以在属性中设置Font,就好像它是一个“普通”标签对象。