Caption Property (Visual FoxPro)
Specifies the text displayed in the caption of an object. Available at design time and run time.
Object.Caption[ = cText]
Specifies text displayed with an object. The maximum number of characters for the Caption property is 255. The following table describes how captions display depending on the object.
Caption displays in the title bar of the form. When the form minimizes, the caption displays to the right of the form icon.
Caption displays on the tab of each page in the page frame.
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.
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.).
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.
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.