Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Aligning Labels vertically in VB.Net

Status
Not open for further replies.

davepruce

Programmer
Dec 18, 2001
17
0
0
GB
Put 2 labels on a form that you want to be right aligned and one above the other.
Make one have text of "Receipt Date:", and one have "Customer Code:", and make both aligned 'Middle Right', just like you would with a data-entry form!
Now can somebody tell me how to line up the ":", one above the other, while keeping the labels the same size.
Of course I could mess (that was not the first word that sprang to mind!) about moving them around till they line up, but thats not the point!!!
Am I missing something really basic?
Cheers
Dave
 
Take a look at the options under the "Format" menu. They usually do the trick. You have to select both labels, then go to "Format" and choose "Align". It will be in there. Unfortunately, it doesn't always do what I expect it to do... but 90% of the time it's right on.

Ben
A programmer was drowning. Lots of people watched but did nothing. They couldn't understand why he yelled "F1!"
 
Nope, tried every one!
If you start with "Cust Code:" and gradually extend it to "Customer Code:" you'll see it gets more and more out of line!
But thanks for the thought anyway!!
Dave
 
Well, too bad.

If you ever find a way to line them up properly without going pixel-by-pixel, make sure to post it here. That one's bugged me on several occasions.

Ben
A programmer was drowning. Lots of people watched but did nothing. They couldn't understand why he yelled "F1!"
 
I select multiple controls by selecting the first then holding CTL while I select the others. In this case, the "dominant" control is the last control selected while CTL is pressed. Then I select the formatting from the Format Menu. It orks for me every time. Go to Help menu, select Index and type in "dominant control" for further info.

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Ok im a newbie, but maybe align the left text box right
and the right text box left.
then just put your : in the middle???


if it is to be it's up to me
 
The problem we're talking about is that the auto-align doesn't align the text in the label... it aligns the label control itself with another. Occasionally, if you have 2 labels (place one above the other) and set their TextAlign Properties to MiddleRight, then use one of the format options to align the right edges, They won't line up properly. For instance:

Make 2 labels with the following text (include the :)

Spot Type:
Comment:

Set TextAlign for each to MiddleRight.
Set Font settings to Georgia, Italic, 10pt.

Make both controls the same size, then attempt to align the text using the Format Menu.

On my screen, "Comment:" appears to be about 2 pixels further to the right than "Spot Type:". It's just enough to look like it's out of alignment, which is annoying if you have several user entry fields that you want to label.

Ben
A programmer was drowning. Lots of people watched but did nothing. They couldn't understand why he yelled "F1!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top