SizeToFit Method

SizeToFit Method

See Also         Example         Applies To

You can use the SizeToFit method to size a control so it fits the text or image that it contains. For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

Syntax

control.SizeToFit

The SizeToFit method has the following argument.

Argument Description
control A control that displays text or an image, including the label, toggle button, command button, image, unbound object frame, and subform/subreport controls.

Remarks

The use of the SizeToFit method is equivalent to selecting a control on a form or report, pointing to Size on the Format menu, and clicking To Fit. You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl function to size new controls that you have created in code.

Note   Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.