Alignment
This is a property of many controls. Most of the time, it determines where the Caption or Value of the control appears. Whether Alignment applies to Caption or Value depends on the control. For controls that let you type into them (text box, edit box, combo box, spinner), Alignment is about Values. For other controls (check box, option button, header, label), Alignment is about Captions. For grid columns, Alignment determines the position of the data shown in the column when the contained control doesn't have focus, and provides a default alignment for the contained control. In this case, it offers a lot more choices than for the other controls.
Usage |
oObject.Alignment = nAlignment nAlignment = oObject.Alignment |
Parameter |
Value |
Meaning |
nAlignment |
0 |
Left—this is the default for most controls. For columns, this value means "middle left"—flush left and vertically centered. |
1 |
Right—this is the default for spinners and for a number of controls in the Middle Eastern version of Windows (in other words, for languages written right-to-left). For columns, this is "middle right"—flush right and vertically centered. |
|
2 |
Center—doesn't apply to some controls. For columns, this is "middle center." |
|
3 |
Automatic—applies only to text boxes and columns and is their default. It lets them adjust automatically based on whether the Value is character (left-justified) or numeric (right-justified). |
|
4 |
Top Left—applies to columns and headers only. |
|
5 |
Top Right—applies to columns and headers only. |
|
6 |
Top Center—applies to columns and headers only. |
|
7 |
Bottom Left—applies to columns and headers only. |
|
8 |
Bottom Right—applies to columns and headers only. |
|
9 |
Bottom Center—applies to columns and headers only. |
Alignment has a whole collection of weird behaviors. With text boxes and spinners, if you use something other than the default alignment, the text or number bounces around when it receives and loses focus. Frankly, we think this is a bug, though it's in the "annoying" category rather than the "keeps you from getting something done" category. |
In VFP 3, using right alignment with option buttons causes a problem with the focus rectangle. When focus lands on a right-aligned check box or option button, the left-hand side of the focus rectangle is missing. This bug was fixed in VFP 5. |
Alignments other than Left are a mess in combo boxes. When you use Center or Right alignment, the value in the combo disappears entirely in VFP 3. In VFP 5 and later, the value doesn't get aligned properly until you leave the combo. As long as it still has focus, the value is too far to the left. |
Non-Sparse columns don't pick up their vertical alignment immediately. When you start the form, the data is at the top. As soon as you click into the column, the data moves to the correct vertical position. You have to tab or click into each cell or do some scrolling to get all the data where it should be. Yuck! |
Columns containing check boxes don't let you use any of the center alignments to center the check box itself in the column. In addition, check boxes in grids ignore the vertical alignment you specify (unless it's middle). |
Example |
oForm = CREATE("Form") oForm.Show() oForm.AddObject("MyCheck", "CheckBox") oForm.MyCheck.Visible = .T. oForm.MyCheck.AutoSize = .T. oForm.MyCheck.Caption = "Checker" oForm.MyCheck.Alignment = 1 && Right |
See Also |