Question

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

default ListView render

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.

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top