How to add an image to the active item in an imagecombo control in vb6

eneate
eneate used Ask the Experts™
on
Hi

I have code to add images to the list of combo items in an image combo control which runs fune, but i can't find a way to add an image to the active entry (not the drop list. I can get the index of the required image but can't find the syntax that will allow me to add it to the active entry.

It has tobe something simple, i use this to get the id of the image

n = 1 'blank icon
    For j = 1 To frmoptions.ImageList1.ListImages.Count
        If last_language = Me.ImageList1.ListImages.Item(j).Key Then n = j 'does tag match language name?
            Next

this gets the string of the selected item and compares it to the key of the image, if they match this is the id, i need the next bit to load the selected image in???

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Commented:

ImageCombo1.ComboItems.Add 1, , "Apple", "a"
ImageCombo1.ComboItems.Add 2, , "Peach", "b"
ImageCombo1.ComboItems.Add 3, , "Pear", "c"
    
ImageCombo1.SelectedItem = ImageCombo1.GetFirstVisible

Open in new window

Top Expert 2010

Commented:
There was a problem in that my comment was removed... I'll try again
In the example "Apple" is the text displayed and the "a" is the image "key" that you assigned to the imageList so you will want to replace them to suit your requirment. Which it appears that you would replace "a" with  last_language.

ImageCombo1.ComboItems.Add , , "Apple", "a"

Open in new window

Top Expert 2010
Commented:
To change existing items image.
Dim currentItem As Long
currentItem = ImageCombo1.selectedItem.Index
ImageCombo1.ComboItems.item(currentItem).Image = "c" 'key

Open in new window

Author

Commented:
Hi

That did it thanks again

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial