Label TextAlign

bufer24

Active member
Joined
Mar 27, 2008
Messages
35
Programming Experience
3-5
Hi, I have a simple but tricky problem: I have a label inside a container control (form, panel, or whatever). The labels anchor is set to bottom & right, auto-size is set to true and the textalign property is set to middle right. The length of the text changes during runtime. I want to ensure, that the right edge of the label stays sticked to the right edge of its container no matter what the length of the lebels text is. I know I could do that in code, but is there a simple way to do it at the design-time?

Thanks
 
When you Anchor the control stays at a fixed distance to the anchored edge of container and is only dynamically resized/relocated when container resizes. So your label will stay for example 100 pixels from right no matter what size the label is. The only way I see to do this without using code is to Dock it to bottom and and set AutoSize to False, then label will fill the entire bottom of the container, and with text right aligned the label will seem to expand from the right edge. This will at least allow text to expand to the full width of container, or multiple lines if you have set the label height larger to make room for this.
 
I decided to rather resize the label in code, because there are other controls to the left of the label. Thank you anyway ;)
 
Back
Top