View Full Version : How do I keep a Label Object a constant size?
Jim Smiley
01-31-2006, 11:38 PM
I'm Setting the text in a Label, but I want the centerpoint of the text to stay in one location, centered above an image. If for example I start with "This is my label text", correctly aligned, when I Set the text to "New Text", the centerpoint shifts to the left as the Label object resizes. If I put in extra spaces " New Text " it aligns correctly. I've tried force the Label length with Label.SetSize and also change only the text tblLabelProperties.Text = "New Text" after Label.GetProperties, but the text is never correctly centered.
Any suggestions on another way to accomplish this?
Jim Smiley
Corey
01-31-2006, 11:58 PM
Hi, if you set your label to "center align" (see attached) it should help some... :yes
Jim Smiley
02-01-2006, 10:25 AM
Corey;
Thanks for the quick response. My label was configured as you suggested and worked fine with the original text. (See Right attachment) The problem comes when I change the text. (See Wrong attachment)
Is it possible to use one Label Object and keep the center of the text at a specific coordinate or am I going to need 24 seperate Labels?
Thanks for the help
JRS
Brett
02-01-2006, 12:24 PM
What about using a Paragraph object instead of a Label? Then you can set the paragraph to stretch across the entire area and center the text. Unless there is a specific reason you are using a Label, that would be the way to go.
If you do want to use a label, set the text, get the size of the object and then calculate the center:
X = (MaxWidth - LabelWidth) / 2
Then set the position to X.
Jim Smiley
02-01-2006, 12:44 PM
Paragraph makes too much sense.
I guess since I started with a Label, I convinced myself that was the way to go. Couldn't see the forest, till a tree fell on me.
Corey
02-01-2006, 02:29 PM
Couldn't see the forest, till a tree fell on me.
Hee. :) :)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.