Newbie: Aligning Labels and TextBoxes on form

S

Sal Bompensaro

Hi,

When I design forms, I frequently have a lower-right aligned Label to
the left of a TextBox. For example, I might have a Label with the Text
property set to "Name:" and a TextBox to the immediate right where the user
types his name. It's very hard to get the bottom of the label to align with
the bottom of the text box. I discovered that VS.NET will perform the
alignment for me if I select both items and use Format | Align | Bottoms.

When dealing with long forms containing dozens of Label-TextBox pairs, I
run into problems when I try to select ALL of the controls and, for example,
move them all down an inch or two. I might do this if I realize that I
forgot to include a particular label-textBox pair at the top of the form.
When I move everything down (or up), I lose my alignment. The Labels and
TextBoxes no longer have aligned bottoms. They are close, but not a match.
This means I have to re-select each of the pairs and align them one by one
EACH and every time I decide to change the form in a way that moves these
pairs around. This is getting frustration for me.

Is this a bug? Is there a workaround? Thanks.

Sal B.
Witness Protection Program ID#19730127
 
G

Guest

Hi Sal, You can call this bug in one way. However the work around is pretty
simple and straight forward.
1. Set the form’s grid size to some EVEN number. (Ex: 2,2 or 4,4 or 8,8)
2. Set the height of the Label and the textbox to EVEN numbers value as
well. (By default Visual Studio sets the size of a label to 100,23 and the
size of the text box to 100,20.)
That all you will need to do. You are good to go!!

Needless to explain, you must have understood the core of the issue now.

BTW, If you don’t want to change the size if the components, do a select all
and move them around by drag and drop. (USE THE MOUSE, DON’T USE THE ARROW
BUTTONS)

-KISHORE BABU TANETY
 
S

Sal Bompensaro

Hi Sal, You can call this bug in one way. However the work around is
pretty
simple and straight forward.
1. Set the form's grid size to some EVEN number. (Ex: 2,2 or 4,4 or 8,8)
2. Set the height of the Label and the textbox to EVEN numbers value as
well. (By default Visual Studio sets the size of a label to 100,23 and the
size of the text box to 100,20.)
That all you will need to do. You are good to go!!

I can't seem to make your solution work. Consider:

- Create a new WinForms project. The default size of the form is 300x300
[even numbers].

- Drag a label on to the form. Set it's height to 16. Set it's TextAlign
property to BottomRight.

- Drag a text box on the form and place it to the right of the label.

- Holding the control key, select first the TextBox and then the Label.
Select Format | Align | Bottoms. The two controls are now aligned properly.

- Select both controls and drag them with the mouse down a few inches.
The controls are no longer aligned properly... That's basically my problem.

Sal
 
G

Guest

Ooops, I think you miss read my sentance. Or may be i should have framed my
sentance better.
I was not mentioning the size of the frame, but I was mentioning the
Gridsize. I have checked it again and it works Sal.

Sal Bompensaro said:
Hi Sal, You can call this bug in one way. However the work around is pretty
simple and straight forward.
1. Set the form's grid size to some EVEN number. (Ex: 2,2 or 4,4 or 8,8)
2. Set the height of the Label and the textbox to EVEN numbers value as
well. (By default Visual Studio sets the size of a label to 100,23 and the
size of the text box to 100,20.)
That all you will need to do. You are good to go!!

I can't seem to make your solution work. Consider:

- Create a new WinForms project. The default size of the form is 300x300
[even numbers].

- Drag a label on to the form. Set it's height to 16. Set it's TextAlign
property to BottomRight.

- Drag a text box on the form and place it to the right of the label.

- Holding the control key, select first the TextBox and then the Label.
Select Format | Align | Bottoms. The two controls are now aligned properly.

- Select both controls and drag them with the mouse down a few inches.
The controls are no longer aligned properly... That's basically my problem.

Sal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top