jerdub1993
jerdub1993

Reputation: 475

Windows Forms - How to prevent wrap/multiline on System.Windows.Forms.Label?

How would I prevent a string in a System.Windows.Forms.Label from wrapping to a second line? If I set the size to, say, 90x20 and the text extends past 90px, it'll wrap and you see the top of the wrapped text underneath the other text.

I can change the height from 20 to 15 and it hides the wrapped text, but the text is of course still wrapping.

I set the width to 90 because if I don't, it'll overlap over the object to the right. So how would I actually prevent the text from wrapping? Or if you have an idea how I can better accomplish this I'm open to it.

Upvotes: 0

Views: 562

Answers (1)

Theo
Theo

Reputation: 61228

You can set these properties to your label (let's call it '$myLabel')

$myLabel.Size         = '90, 20'
$myLabel.AutoSize     = $false
$myLabel.AutoEllipsis = $true

This will truncate lines of text that are too long and append ... to it, denoting that there is more text than can be displayed

Upvotes: 1

Related Questions