|
-
Jun 11th, 2005, 02:26 PM
#1
Thread Starter
Frenzied Member
image List problems, using list box [resolved]
Right i have two controls, a list box and an image box. The list box is populated with random values, of which coraspond (spelling???) with the images in the image list, so when i click on the list box i want the correct image to be displayed.
How would i do this?
Thank you in advance
ILMV
Last edited by I_Love_My_Vans; Jun 11th, 2005 at 02:48 PM.
-
Jun 11th, 2005, 02:31 PM
#2
Re: image List problems, using list box
How do they correspond (it takes a Swede to learn an Englishman how to spell in English ) to each other?
-
Jun 11th, 2005, 02:33 PM
#3
-
Jun 11th, 2005, 02:34 PM
#4
Thread Starter
Frenzied Member
Re: image List problems, using list box
Well the values in the list box will be for example "Spade12", or "Club1", you can see the idea, well i have named each 'corresponding' card the same, for example "Spade12" etc.
-
Jun 11th, 2005, 02:40 PM
#5
Re: image List problems, using list box
 Originally Posted by I_Love_My_Vans
Right i have two controls, a list box and an image box. The list box is populated with random values, of which coraspond (spelling???) with the images in the image list, so when i click on the list box i want the correct image to be displayed.
How would i do this?
Thank you in advance
ILMV
First add a list box, an Image Control and a ImageList to a form. Use the default names for each control. Then add a few images to the ImageList and then paste this code:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim a As Long
With Me.List1
For a = 1 To Me.ImageList1.ListImages.Count
.AddItem "Picture " & a
Next a
End With
End Sub
Private Sub List1_Click()
Dim indx As Long
indx = Me.List1.ListIndex + 1
Me.Image1.Picture = Me.ImageList1.ListImages(indx).Picture
End Sub
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Jun 11th, 2005, 02:40 PM
#6
Re: image List problems, using list box
The easiest way would be if you have added the ListItems using "Spade12" or "Club1" as the Key value. You could then use code simular to this:
VB Code:
Private Sub List1_Click()
Set ListView1.SelectedItem = ListView1.ListItems(List1.Text)
End Sub
-
Jun 11th, 2005, 02:47 PM
#7
Thread Starter
Frenzied Member
Re: image List problems, using list box
-
Jun 11th, 2005, 02:50 PM
#8
Re: image List problems, using list box
 Originally Posted by I_Love_My_Vans
Well the values in the list box will be for example "Spade12", or "Club1", you can see the idea, well i have named each 'corresponding' card the same, for example "Spade12" etc.
Ok, change the List_Click Event in my code to:
VB Code:
Private Sub List1_Click()
Me.Image1.Picture = Me.ImageList1.ListImages(Me.List1.Text).Picture
End Sub
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|