AutoSize Property

AutoSize controls whether the Text object automatically picks a new font that will fit into the bounding rectangle as the Caption changes. If AutoSize is set to True, the size of the bounding rectangle is recalculated. If set to False, the FontSize of the Text object is recalculated.

Syntax

object.AutoSize [= Boolean]

Properties

The AutoSize property syntax has these parts:

Part

Description

object

An object expression that evaluates to an object in the Applies To list.

Boolean

Whether or not to automatically update the object's size to fit its contents.

Settings

The settings for Boolean are:

Value

Description

True

Automatically resize the object to display its entire contents. (Default)

False

Maintain the size of the object constant, adjust the FontSize to fit inside the bounding rectangle.

Remarks

For controls with captions, the AutoSize property specifies whether the control automatically adjusts to display the entire caption. For controls without captions, this property specifies whether the control automatically adjusts to display the information stored in the control. In a ComboBox, for example, setting AutoSize to True automatically sets the width of the display area to match the length of the current text.

For a single-line text box, setting AutoSize to True automatically sets the width of the display area to the length of the text in the text box.

For a multi-line text box that does not contain text, setting AutoSize to True automatically displays the text as a column. The width of the text column is set to accommodate the widest letter of that font size. The height of the text column is set to display the entire text of the TextBox. For a multi-line text box that contains text, setting AutoSize to True automatically enlarges the TextBox vertically to display the entire text. The width of the TextBox does not change.

The behavior of the object by changing the AutoSize property is dependent upon the ScalesWidth property. The following table illustrates the dependencies:

Value

ScalesWidth Value

Resulting Behavior

True

True

Bounding rectangle is recalculated to fit the text.

False

True

The FontSize is recalculated to fit the bounding rectangle.

True

False

Bounding rectangle is recalculated to fit the text.

False

False

The text is clipped.

NOTE: If you manually change the size of a control while AutoSize is True, the manual change overrides the size previously set by AutoSize.

 

Applies To