Stretch Property

See AlsoITC2KX              Example12C3T1Y>Low

Applies To



Determines whether a picture stretches to fit the size of an image control.


[form.]image.Stretch[ = { True|False}]


The Stretch property settings are:

Setting          Description


True              The picture resizes to fit the control.

False             (Default) The control resizes to fit the picture.



If Stretch is True, resizing the control also resizes the picture it contains.

Data Type

IntegerDOKXHY (Boolean)

See Also


Image Property6AEZWAR

Picture Property4GBE5Q


Programmer's Guide:

Chapter 15, "Creating Graphics for Applications"

Stretch Property Example

The example loads an arrow icon from your icons directory into an image control.  The arrow crawls across the form when Stretch is True, and hops across the form when Stretch is False.  To try this example, paste the code into the Declarations section of a form that contains an image control, a check box and a timer control.  Then press F5 and click the form.  Be sure to check the path to your icons directory and change it if necessary.  To see the effects of the Stretch property, click the check box and then click the form again.

Dim ImgW                              ' Declare variable.

Sub Form_Load ()

   ' Load an icon into the image control.

   Image1.Picture = LoadPicture("icons\arrows\arw02rt.ico")

   Image1.Left = 0                    ' Move image to left edge.

   ImgW = Image1.Width                ' Save width of image.

   Timer1.Interval = 300

   Timer1.Enabled = False             ' Turn off timer.

   Check1.Caption = "Stretch Property"

End Sub


Sub Form_Click ()

   Timer1.Enabled = True              ' Turn on the timer.

End Sub


Sub Timer1_Timer ()

   Static MoveIcon As Integer         ' Flag for moving the icon.

   If Not MoveIcon Then

      Image1.Move Image1.Left + ImgW, Image1.Top, ImgW * 2


      ' Move the image and return it to original width.

      Image1.Move Image1.Left + ImgW, Image1.Top, ImgW

   End If

   ' If image is off edge of form, start over.

   If Image1.Left > ScaleWidth Then

      Image1.Left = 0

      Timer1.Enabled = False

   End If

   MoveIcon = Not MoveIcon            ' Reset flag.

End Sub


Sub Check1_Click ()

   Image1.Stretch = Check1.Value

End Sub