所有者绘制ListView“涂抹” 滚动时
我有一个所有者绘制的 ListView,当我滚动时它会“涂抹”。 它仅影响最后显示的项目,因为它移动到列表的可见区域......
它看起来像:
废话
废话
废话
……全部都绘制在彼此之上,相距 1 个像素。 DrawItem 事件中的代码的形式
Rectangle rect = new Rectangle(e.Bounds.X + mIconSize.Width,
e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawString(episode.ToString(), this.Font, mBlackBrush, rect);
我完全被难住了。 任何想法不胜感激! 戴夫
I have an ownerdrawn ListView that "smears" when I scroll. It only affects the last displayed item as it moves into the visible are of the list...
It looks like:
Blah
Blah
Blah
...have all been drawn on top of each other 1 pixel apart.
The code in the DrawItem event is of the form
Rectangle rect = new Rectangle(e.Bounds.X + mIconSize.Width,
e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawString(episode.ToString(), this.Font, mBlackBrush, rect);
I'm completely stumped.
Any ideas gratefully appreciated!
Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以通过派生 ListView 并设置
DoubleBuffered = true
来为 ListView 启用双缓冲。 打开双缓冲后,闪烁会明显减少,尤其是在平铺视图中。You can enable double buffering for ListView by deriving from it and setting
DoubleBuffered = true
. There's a noticeable reduction in flicker, especially in Tile view, once you turn Double Buffering on.在详细视图绘图中,所有绘图都在 DrawSubItem(...) 中进行。 问题是为第一个项目调用了drawItem,而为同一个项目调用了DrawSubitem...但边界略有不同。
In detail view drawing do all of your drawing in DrawSubItem(...). The problem is drawItem is getting called for the first item and DrawSubitem is also for the same item ... with slightly different bounds.
另外,int表单自身的属性,可以启用DoubleBuffer。
此外,您还可以使用一些命令。
通过在 google 上搜索 DoubleBuffer C# 可以找到更多信息(抱歉,作为新用户,我无法发布链接)。
also, int the form's own properties, you can enable DoubleBuffer.
additionally, there are a couple of commands you can use.
More information can be found by searching DoubleBuffer C# at google (sorry, as a new user I can't post links).
这是 ListView 控件中的一个已知错误。
This is a known bug in the ListView control.