How should I set WordWrap = false
to a System.Windows.Forms.Label
?
I have a header on a panel, and it should show "MyPanel capt..."
. So I use AutoEllipsis = true
, but it is not sufficient.
I also use "AutoSize = true
", because I want that the label takes the minimum space possible.
Apropos, Visual Basic 6.0 did it.
I've got a similar effect working using:
label1.AutoSize = false;
label1.AutoEllipsis = true;
and sizing the label area to be one line in height only.
I'm pretty sure you can't prevent labels from wrapping. An alternate (if slightly crude) option is to set the label to auto-size (so the width grows with the text), and then put a Control next to it that sits in front of it in the z-order. That way, when the label width goes past a certain point the content of the label overlap will be hidden by that other control.
Like I said, it is a pretty crude method of achieving the effect.
Also, if you are trying to use AutoEllipsis, i'm assuming you've disabled AutoResize? I believe it takes precedence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With