Share via


Caption Property

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

Object.Caption[ = cText]

Property Values

  • cText
    Specifies text displayed with an object.

Remarks

Captions are displayed differently depending on the object:

  • For forms, the Caption property specifies the text displayed in the form's title bar. When the form is minimized, this text is displayed below the form's icon.
  • For pages of a PageFrame object, the Caption property specifies the text displayed on the tab of each page.
  • For controls, the Caption property specifies the text displayed on or next to a control.
  • For controls with the Style property set to 1 (Graphical), and for forms that are minimized, the caption is displayed under the icon.
  • For Active Documents, the Caption property determines the text that is displayed on the Active Document's Help menu item when the Active Document's Help menu is merged with the Help menu of its container. The text on the Active Document's Help menu item is followed by "Help." For example, if the Caption property is set to "My Application," the Active Document's Help menu item displays as "My Application Help." The default Caption property value is "ActiveDoc1." If the Caption property is set to the empty string, "Microsoft Visual FoxPro" is displayed as the Help menu item.

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.

See Also

AutoSize Property | BorderStyle Property | Name Property | Style Property | Width Property

Applies To: ActiveDoc Object | CheckBox Control | CommandButton Control | Form Object | Header Object | Label Control | OptionButton Control | Page Object | _SCREEN | ToolBar Object