Caption Property

Applies To   See Also

Specifies the text displayed in an object's caption. Available at design time and run time.

Syntax

Object.Caption[ = cText]

Settings

cText

Specifies text displayed with an object.

Remarks

Captions are displayed differently depending on the object:

When you create a new form or control, its default caption is the same as the default Name property setting. This default caption includes the object class and an integer, such as Command1, Combo1, or Form1.

The Name property is the way to refer to an object in code; the Caption property is what appears on the screen to identify the control. These two properties start out with the same value, but are set independently thereafter.

If there is no Width property setting specified for the control, the control is automatically sized to hold the caption.

For CommandGroup and OptionGroup objects, the caption is displayed only if the BorderStyle property is set to 1 (Fixed Single).

For a Label control, set the AutoSize property to true (.T.) to automatically resize the control to fit its caption. The maximum number of characters for the Caption property for a Label control is 256.

To assign an access key to a control, include a backslash and a less-than sign (\<) in the caption immediately preceding the character you want to designate as the access key. A user can then press ALT and the specified character to move the focus to that control. If the control is a command button, check box, or option button, pressing ALT and the specified character also has the effect of clicking the control.

Access keys are available only if KEYCOMP has been set to WINDOWS. If KEYCOMP is set to MAC (the default), access keys are not available, and the access key letter in a caption is not underlined.