Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatically center a label control
Message
From
14/01/2007 00:11:41
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
13/01/2007 23:59:02
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6
Miscellaneous
Thread ID:
01185419
Message ID:
01185420
Views:
18
>If I want to center my label programmatically, how can I do that. I set the value of caption at run-time.
>
>So I do something like thisform.label1.left=(thisform.width-thisform.label1.width)/2
>
>But this won't center the label. Any help?

That should center the label, but if the text in the label is shorter than the label itself, it would be, well, to the left of the center if the label is left justified.
Set the label's .alignment=2 (centered) in addition to your centering it. It should look right then.

BTW, you don't have to calculate the position - this should be possible at design time by a button in the Layout toolbar, there is one to center the control horizontally.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform