Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What is wrong with this code?
C#
Private Sub Form_Load()
Dim ImageList0 As ImageList
Dim ImageCombo1 As ImageCombo
Dim objNewItem As ComboItem
Set ImageCombo1.ImageList = ImageList0 'here is the error'

Set objNewItem = ImageCombo1.ComboItems.Add(1, , "Apricot", "Apricot")
objNewItem.Indentation = 2
ImageCombo1.ComboItems("Apricot").Image = 1
ImageCombo1.ComboItems("Apricot").Image = "Apricot"
ImageCombo1.ComboItems("Apricot").SelImage = "Apricot"

End Sub

I have two components on the form :ImageList, with populated images and imagecombobox, to which I am assigning the imagelist. My above code doesn't work. Pls, help with the better solution or code.

and ImageList0 is the name of the component, i am not assigning 0 to it. Imagelist contains 4 images.
Posted
Updated 13-Jul-12 5:30am
v4
Comments
[no name] 12-Jul-12 15:05pm    
Without more information it is hard to tell. Probably because you are assigning a null object to the ImageList.

Set ImageCombo1.ImageList = ImageList0
ImageList0 is nothing.

Why are you assigning it and then adding data to imagecombo directly? Populate the list first and then assign the list to ImageCombo.
 
Share this answer
 
Hi, Sandeep,
thanks for the quick response. I need image combo on my form, so it shows images and text next to it. I put ImageList active x first and put all my images there. Then I was trying to assign imalist to imagecombo, and the error pops up. Then I decided to direct code, but still no result. I am doing this first time and this is very crucial to my project. Can you help? Pls, send me the code which might work. I am not using third parties components, i am trying to make authentic microsoft active x to work for me. i would highly appreciate your help.
 
Share this answer
 
Added .object
and it worked.

Thanks, guys
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900