Image Control

Description

Displays a picture on a form.

Remarks

The Image lets you display a picture as part of the data in a form. For example, you might use an Image to display employee photographs in a personnel form.

The Image lets you crop, size, or zoom a picture, but does not allow you to edit the contents of the picture. For example, you cannot use the Image to change the colors in the picture, to make the picture transparent, or to refine the image of the picture. You must use image editing software for these purposes.

The Image supports the following file formats:

  • *.bmp
  • *.cur
  • *.gif
  • *.ico
  • *.jpg
  • *.wmf
Note You can also display a picture on a Label. However, a Label does not let you crop, size, or zoom the picture.

The default event for the Image is the Click event.

Properties

AutoSize property, BackColor property, BackStyle property, BorderColor property, BorderStyle property, ControlTipText property, Enabled property, Height, Width properties, LayoutEffect property, Left, Top properties, MouseIcon property, MousePointer property, Name property, Object property, OldHeight, OldWidth properties, OldLeft, OldTop properties, Parent property, Picture property, PictureAlignment property, PictureSizeMode property, PictureTiling property, SpecialEffect property, Tag property, Visible property.

Methods

Move method, ZOrder method.

Events

BeforeDragOver event, BeforeDropOrPaste event, Click event, DblClick event, Error event, MouseDown, MouseUp events, MouseMove event.

See Also

Label control.

Example

The following example sets the dimensions of an Image to the size of a TabStrip's client area when the user clicks a CommandButton. This code sample uses the following properties: Height, Left, Top, Width, ClientHeight, ClientLeft, ClientTop, and ClientWidth.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • A CommandButton named CommandButton1.
  • A TabStrip named TabStrip1.
  • An Image named Image1.
    Private Sub UserForm_Initialize()
        CommandButton1.Caption = "Size Image to Tab Area"
        CommandButton1.WordWrap = True
        CommandButton1.AutoSize = True
    End Sub
    
    Private Sub CommandButton1_Click()
        Image1.ZOrder (fmFront)             'Place Image in front of TabStrip
    
        'ClientLeft and ClientTop are measured from the edge of the TabStrip, 
        'not from the edges of the form containing the TabStrip.
        Image1.Left = TabStrip1.Left + TabStrip1.ClientLeft
        Image1.Top = TabStrip1.Top + TabStrip1.ClientTop
        Image1.Width = TabStrip1.ClientWidth
        Image1.Height = TabStrip1.ClientHeight
    
    End Sub