Visual Basic Reference

Caption Property (DEDesigner Extensibility)

See Also    Example    Applies To

Returns or sets the label, or caption control, that is set when a DEAggregate or DEField object is dragged from the Data Environment designer and dropped onto a Visual Basic form or report. To use the caption in a drag-and-drop operation, you must first specify that a caption will be created when the object is dropped.

  • Form The text that displays in the title bar of the Form or MDIForm object. When the form is minimized, this text displays below the form's icon.

  • Control The text that displays in or next to a control.

  • MenuLine object The text that displays for a Menu control or an object in the MenuItems collection.

Note For a Menu control, the Caption property is generally read/write at run time. However, the Caption property is read-only for menus that are exposed or supplied by Visual Basic to add-ins, such as the MenuLine object.

Syntax

object.Caption [=string]

The Caption property syntax has these parts:

Part Description
object An object expression that evaluates to an item in the Applies To list. If object is omitted, the form associated with the active form module is assumed to be object.
string A string expression that defines the  textual caption that drops onto the form.

Remarks

When you create a new object, its default caption is the default Name property setting. This default caption includes the object name and an integer, such as Command1 or Form1. For a more descriptive label, set the Caption property.

You can use the Caption property to assign an access key to a control. In the caption, include an ampersand (&) immediately preceding the character you want to designate as an access key. The character is underlined. Press the ALT key plus the underlined character to move the focus to that control. To include an ampersand in a caption without creating an access key, include two ampersands (&&). A single ampersand is displayed in the caption and no characters are underlined.

The caption size of the Label control is unlimited. For forms and all other controls that have captions, the limit is 255 characters.

To display the caption for a form, set the BorderStyle property to either Fixed Single (1 or vbFixedSingle), Sizable (2 or vbSizable), or Fixed Double (3 or vbFixedDouble). If a caption is too long for the form's title bar, the caption is clipped. When an MDI child form is maximized within an MDIForm object, the caption of the child form is included in the caption of the parent form.

Tip   For a label, set the AutoSize property to True to automatically resize the control to fit its caption.