changing image based on pulldown
Hi,
First, say your image control is Image1 and your drop dow is Combobox1.
'To capture the user change of choice use the Combobox1_Click sub:
Private Sub ComboBox1_Click()
Dim i As Long
i = ComboBox1.ListIndex 'user choice
msgbox "the user has just changed to choice " & i
End Sub
Now to load images when the user changes choice: 2 Methods
'1 -- LoadPicture which requires the user to have the pictures on the hard
drive.
Private Sub ComboBox1_Click()
Dim i As Long
i = ComboBox1.ListIndex 'user choice
If i = 0 Then 'if 1 then this image
Image1.Picture = LoadPicture("C:\Program Files\Microsoft
Office\Office10\Bitmaps\Styles\ACBLUPRT.GIF")
ElseIf i = 1 Then 'if 2 then this image
Image1.Picture = LoadPicture("C:\Program Files\Microsoft
Office\Office10\Bitmaps\Styles\ACSUMIPT.GIF")
Else
End If
End Sub
'2 -- ImageList control 'Much Easier i think
You can use the ImageList control to load pictures into your Image control.
- Add a ImageList control:
From the toolbox, right-click and choose 'Additional Controls', browse to
the 'Microsoft ImageList Control' latest version (probably SP6)
Now the control is added to the Toolbox
Add one to the Userform
- Load pictures into the ImageList control
in the properties for the image list control, select Custom. The
Properties form of the ImageList pops up. In the Images tab, load each
picture you want to use in the order they would match the items in the
drop-down. Then close the dialog box.
- now you can use the Imalist control as follow:
Private Sub ComboBox1_Click()
Dim i As Long
i = ComboBox1.ListIndex 'user choice
Image1.Picture = ImageList1.ListImages(i + 1).Picture
End Sub
--
Regards,
Sébastien
<http://www.ondemandanalysis.com
"Sandy Ryan" wrote:
i have a pulldown - and need to change the image displayed on the form, based
on the selected item... i have the image control, but can't find how to
program it based on the pulldown.
More info -- i have a validation data sheet that has the pulldown values in
one column and the location of the file in another column
thanks
for the help
|