绘图 ListViewItem 超出 VisibleClipBounds
我正在尝试在自定义用户控件上手动绘制 ListViewItems。 控件本身是作为私有成员存储在类上的 ListView 的包装器。
附加了一个 DrawListViewItemEventHandler 来允许手动绘制这些项目,并且在大多数情况下这似乎是有效的。 我遇到的问题是 ListViewItem(在大图像模式下)的文本很长。
我在具有各种主题的 ListViewItem 周围绘制一个边界矩形,然后使用 Graphics.MeasureString() 测量文本的大小并手动绘制文本。 然而我发现垂直绘图被裁剪为 2.5 行文本,因为标题超出了我所传递的图形上下文的 VisibleClipBounds 范围。
这看起来有点奇怪,但我不确定为什么会发生这样的事情,并且不知道如何解决这个问题。
I'm trying to manually draw ListViewItems on a Custom UserControl. The control itself is a wrapper around a ListView stored as a private member on the class.
There is a DrawListViewItemEventHandler attached to allow manual drawing for these items, and for the most part this seems to work. The problem I have is where the text for the ListViewItem (in large image mode) is long.
I'm drawing a bounding rectangle around the ListViewItem with various themes, and I then measure the size of the text using Graphics.MeasureString() and manually draw the text. However what I'm finding is that the vertical drawing is cropping at 2.5 lines of text, because the caption is falling outside of the VisibleClipBounds of the graphics context I have been passed.
It seems a bit of a strange but I'm not sure why such a thing should happen and can't figure out how to get around the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Tile view 和 TileSize 为自己提供足够的空间来绘制文本。
ListView 不能保证绘制所有文本:文本可能很大。
You could use Tile view and TileSize to give yourself enough space to draw your text.
The ListView can't guarantee to draw all its text: the text could be huge.