Label.AutoEllipsis text alignment

UncleRonin

Well-known member
Joined
Feb 28, 2006
Messages
230
Location
South Africa
Programming Experience
5-10
I've come across this quite a few times before but now it's starting to get irritating. I have labels that are LeftCenter aligned. Sometimes the text in the label will exceed the boundary so I use AutoEllipsis to clean it up a bit. The problem is that as soon as AutoEllipsis is used to changes the alignment of the text to LeftTop as though the extra text would be displayed beneath. Is there some way to prevent this from happening at all? I mean surely this can't be the desired behaviour.
 
That does seem like a bit of a bug. Is your Label only supposed to display a single line of text? If so then I'd suggest that you adjust the height so that it can't change the alignment.
 
The label is only supposed to display the single line of text, yes. The label is bordered since it's for display and a result of an action. So shrinking the height will look pretty siff *scratches* I could change that but since it's one of those things that is used all over the place it would take a pretty long time and aesthetically (at least to my non UI background) it's not ideal.

Do you know if this happens in Framework 3 or 3.5? Maybe they did fix it after.
 
Same in 3.5. There may be a reason for it but I don't know what it could be. You could create a UserControl with a border and a Label on it. That way you'd get the same look without the alignment issue. It would be a matter of Find & Replace to update your code so not much effort.
 
Hmm... from past experience Find & Replace can have... interesting... results :) But ja, this shouldn't ever really happen during normal use so it is possible to leave as is. There is the possibility of inheriting from label and changing this behaviour or creating a custom user control like you say.

The question is: why haven't the fixed it!?! Having something change it's specified alignment isn't a very good plot, especially when respecifying the alignment has no effect. Strange. Thanks for your help though. I often run into this so I think I may just inherit and create my own control to get around this in the future.
 
Back
Top