Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextRenderer. How to render text multiline with endellipsis?

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.

like image 969
DimDim Avatar asked Jan 19 '26 10:01

DimDim


1 Answers

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);
like image 77
LarsTech Avatar answered Jan 21 '26 00:01

LarsTech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!