TextRenderer.如何用内斜线呈现文本多行? [英] TextRenderer. How to render text multiline with endellipsis?

查看:148
本文介绍了TextRenderer.如何用内斜线呈现文本多行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何呈现这样的文本(简单的列表视图)?

How i can render text like this(simple listview)?

尝试这样的代码不会出现省略号:

Trying the code like this renders no ellipsis:

TextRenderer.DrawText(_listGraphics,
                   anItem.Text, GetItemFont(anItem),
                   textRec,
                   Color.FromKnownColor(KnownColor.ControlText),
                   TextFormatFlags.Top| TextFormatFlags.EndEllipsis|
                   TextFormatFlags.WordBreak | TextFormatFlags.HorizontalCenter);

如果我删除TextFormatFlags.WordBreak,则文本变为单行.

if I remove TextFormatFlags.WordBreak then the text becomes single line.

它可以在拖动项目时手动热跟踪项目.

Its to manual hot track the items while Drag-n-drop over them.

推荐答案

正如汉斯(Hans)教给我的那样,通过包含TextBoxControl标志可以为它提供一个标志:

As Hans taught me, there is a flag for that by including the TextBoxControl flag:

TextRenderer.DrawText(e.Graphics, myString, this.Font,
                      textRec, Color.Black, Color.Empty,
                      TextFormatFlags.HorizontalCenter |
                      TextFormatFlags.TextBoxControl |
                      TextFormatFlags.WordBreak |
                      TextFormatFlags.EndEllipsis);

这篇关于TextRenderer.如何用内斜线呈现文本多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆