Compact Framework:用省略号绘制多行字符串
我正在为 Windows Mobile 应用程序创建一个继承自 ListView 的所有者绘制控件。我正在使用 Graphics.DrawString 写出两行文本字符串(使用 .NET CF 3.5)。问题是有些项目的文本特别长,不适合两行。谷歌搜索找到了使用 MeasureString 并手动截断字符串的方法,但这仅适用于单行字符串。有什么方法可以在这里得到省略号,还是我必须接受剪切文本或重新设计以仅使用一行? (两者都不是破坏交易的因素,但省略号肯定会很好。)
I'm creating an owner-drawn control inherited from ListView for a Windows Mobile application. I'm using Graphics.DrawString
to write out a two-line text string (using .NET CF 3.5). Problem is some items have particularly long text that doesn't fit on the two lines. Googling has found methods for using MeasureString
and to manually truncate my string, but this only works on a single-line string. Is there any way to get the ellipses here, or do I have to either accept clipped text or redesign to use only a single line? (Neither is a deal-breaker, but ellipses sure would be nice.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以显示省略号,但您必须执行一些 P/Invoking(有什么新功能?):
NativeMethods 是一个包含我所有本机调用的类。包括:
Yes, you can get the ellipses to display, but you'll have to do some P/Invoking (what's new?):
NativeMethods is a class that has all of my native calls. Including: