Freigeben über


Caption Property

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

Object.Caption[ = cText]

Property Values

  • cText
    Specifies text displayed with an object. The following table describes how captions display depending on the object.
    Object Caption display
    Form Caption displays in the title bar of the form. When the form minimizes, the caption displays to the right of the form icon.
    PageFrame Caption displays on the tab of each page in the page frame.
    Controls Caption displays on or next to the control. If the control displays an icon, setting the PicturePosition property determines the placement of the icon and therefore, the placement of the caption.

Remarks

When you create a new form or control, the default value of the Name property sets the default value of the Caption property. This default caption includes the name of the object class and an integer, for example, Command1, Combo1, or Form1.

Use the Name property to properly refer to an object in code. The Caption property describes only the text that appears on the screen for identifying the control. These two properties begin with the same value, but are set independently thereafter.

If you do not specify a Width property setting for a control, the control is automatically sized to contain the caption.

To automatically resize a Label control to fit its caption, set the AutoSize property to True (.T.). The maximum number of characters for the Caption property of 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 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.

To add an underline to a character in a column header caption, precede the character with an ampersand (&). If you want to include the character "&" in a column header caption, use two consecutive & characters. Note that this does not cause the letter to behave as an access key, but only underlines the header caption character.

Example

This example demonstrates the use of the Caption property to change the main Visual FoxPro window caption from Microsoft Visual FoxPro to the current version number of Visual FoxPro.

_SCREEN.Caption=VERSION()

See Also

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

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