Export (0) Print
Expand All
Expand Minimize

Centered Property

Visual Studio .NET 2003

Specifies whether a CheckBox control is centered within the control boundaries.

CheckBox.Centered [= lExpr]

Property Values

lExpr
Logical data type. The following table lists the values of lExpr.
lExpr Description
False (.F.) The CheckBox control is not centered within the control boundaries. (Default)
True (.T.) Centers the CheckBox control within the control boundaries.

Remarks

If a CheckBox control is not contained in a grid, the control is centered within its own control boundaries.

Centered works in conjunction with the Alignment property. If you supply a caption, the left and right alignment values of the Alignment property determine on which side of the check box the caption appears. If the Centered property is also set to True (.T.), both the caption and check box are centered horizontally and vertically in the grid column.

If the Sparse property of the column is set to True (.T.) (default), the Alignment property of the column determines the placement of text in all the cells in the column. However, when a particular cell gets focus, and the control appears, Visual FoxPro uses the Alignment property of the control. If you set the Sparse property of the column to False (.F.), Visual FoxPro uses the Alignment property of the control and disregards the column's Alignment property.

When the column's Alignment property is set at design time, the designer attempts to set the Alignment property on the controls in the column as well. When that control is a CheckBox, setting the column's Alignment to any of the "center" property values automatically sets the Centered property to True (.T.).

If Centered is True (.T.), the check box remains centered horizontally and vertically in the grid cell as the grid columns and rows are resized.

Example

The following example shows how you can set the Centered property to align a check box with the center of the control and its caption to the right of the check box:

Checkbox1.Centered = .T.
Checkbox1.Alignment = 1   

Example 2

The following example shows how you can set the Centered property to align a check box within the center of a grid column. Setting the Sparse property of the column to False (.F.) specifies that the Alignment property of the control takes precedence over the Alignment property of the grid column:

Column1.Sparse = .F.
Column1.Checkbox1.Centered = .T.
Column1.Checkbox1.Caption = ""

See Also

Properties | Sparse Property | Alignment Property

Applies To: CheckBox Control

Show:
© 2014 Microsoft