Picture Property

Applies To

CheckBox control, CommandButton control, Frame control, Image control, Label control, OptionButton control, Page object, ToggleButton control, UserForm object.

Description

Specifies the bitmap to display on an object.

Syntax

object.Picture = LoadPicture( pathname)

The Picture property syntax has these parts:

Part

Description

object

Required. A valid object.

pathname

Required. The full path to a picture file.


Remarks

While designing a form, you can use the control's property page to assign a bitmap to the Picture property. While running a form, you must use the LoadPicture function to assign a bitmap to Picture.

To remove a picture that is assigned to a control, click the value of the Picture property in the property page and then press DELETE. Pressing BACKSPACE will not remove the picture.

Note For controls with captions, use the PicturePosition property to specify where to display the picture on the object. Use the PictureSizeMode property to determine how the picture fills the object.

Transparent pictures sometimes have a hazy appearance. If you do not like this appearance, display the picture on a control that supports opaque images. Image and MultiPage support opaque images.

See Also

PictureAlignment property, PicturePosition property, PictureSizeMode property, PictureTiling property.

Example

The following example uses a ComboBox to show the picture placement options for a control. Each time the user clicks a list choice, the picture and caption are updated on the CommandButton. This code sample also uses the AddItem method to populate the ComboBox choices.

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

  • A Label named Label1.
  • A CommandButton named CommandButton1.
  • A ComboBox named ComboBox1.
    Private Sub UserForm_Initialize()
        Label1.Left = 18
        Label1.Top = 12
        Label1.Height = 12
        Label1.Width = 190
        Label1.Caption = "Select picture placement relative to the caption."
        
        'Add list entries to combo box. The value of each entry matches the
        'corresponding ListIndex value in the combo box.
        ComboBox1.AddItem "Left Top"        'ListIndex = 0
        ComboBox1.AddItem "Left Center"     'ListIndex = 1
        ComboBox1.AddItem "Left Bottom"     'ListIndex = 2
        ComboBox1.AddItem "Right Top"       'ListIndex = 3
        ComboBox1.AddItem "Right Center"    'ListIndex = 4
        ComboBox1.AddItem "Right Bottom"    'ListIndex = 5
        
        ComboBox1.AddItem "Above Left"      'ListIndex = 6
        ComboBox1.AddItem "Above Center"    'ListIndex = 7
        ComboBox1.AddItem "Above Right"     'ListIndex = 8
        ComboBox1.AddItem "Below Left"      'ListIndex = 9
        ComboBox1.AddItem "Below Center"    'ListIndex = 10
        ComboBox1.AddItem "Below Right"     'ListIndex = 11
        
        ComboBox1.AddItem "Centered"        'ListIndex = 12
        
        ComboBox1.Style = fmStyleDropDownList  'Use drop-down list
    
        ComboBox1.BoundColumn = 0           'Combo box values are ListIndex values
        ComboBox1.ListIndex = 0             'Set combo box to first entry
    
    
        ComboBox1.Left = 18
        ComboBox1.Top = 36
        ComboBox1.Width = 90
        ComboBox1.ListWidth = 90
        
        'Initialize CommandButton1
        CommandButton1.Left = 230
        CommandButton1.Top = 36
        CommandButton1.Height = 120
        CommandButton1.Width = 120
        
        'Note: Be sure to refer to a bitmap file that is present on your
        'Note: system, and to include the path in the filename.
        CommandButton1.Picture = LoadPicture("c:\windows\argyle.bmp")
        CommandButton1.PicturePosition = ComboBox1.Value
    End Sub
    
    Private Sub ComboBox1_Click()
        Select Case ComboBox1.Value
        Case 0  'Left Top
            CommandButton1.Caption = "Left Top"
            CommandButton1.PicturePosition = fmPicturePositionLeftTop
        
        Case 1  'Left Center
            CommandButton1.Caption = "Left Center"
            CommandButton1.PicturePosition = fmPicturePositionLeftCenter
                
        Case 2  'Left Bottom
            CommandButton1.Caption = "Left Bottom"
            CommandButton1.PicturePosition = fmPicturePositionLeftBottom
            
        Case 3  'Right Top
            CommandButton1.Caption = "Right Top"
            CommandButton1.PicturePosition = fmPicturePositionRightTop
        
        Case 4  'Right Center
            CommandButton1.Caption = "Right Center"
            CommandButton1.PicturePosition = fmPicturePositionRightCenter
        
        Case 5  'Right Bottom
            CommandButton1.Caption = "Right Bottom"
            CommandButton1.PicturePosition = fmPicturePositionRightBottom
        
        Case 6  'Above Left
            CommandButton1.Caption = "Above Left"
            CommandButton1.PicturePosition = fmPicturePositionAboveLeft
        
        Case 7  'Above Center
            CommandButton1.Caption = "Above Center"
            CommandButton1.PicturePosition = fmPicturePositionAboveCenter
            
        Case 8  'Above Right
            CommandButton1.Caption = "Above Right"
            CommandButton1.PicturePosition = fmPicturePositionAboveRight
        
        Case 9  'Below Left
            CommandButton1.Caption = "Below Left"
            CommandButton1.PicturePosition = fmPicturePositionBelowLeft
        
        Case 10 'Below Center
            CommandButton1.Caption = "Below Center"
            CommandButton1.PicturePosition = fmPicturePositionBelowCenter
        
        Case 11 'Below Right
            CommandButton1.Caption = "Below Right"
            CommandButton1.PicturePosition = fmPicturePositionBelowRight
        
        Case 12 'Centered
            CommandButton1.Caption = "Centered"
            CommandButton1.PicturePosition = fmPicturePositionCenter
        
        End Select
        
    End Sub