问题
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);
if I remove TextFormatFlags.WordBreak
then the text becomes single line.
Its to manual hot track the items while Drag-n-drop over them.
回答1:
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);
来源:https://stackoverflow.com/questions/17521347/textrenderer-how-to-render-text-multiline-with-endellipsis