How to add pictures in a combobox?

isaacv22

New Member
Joined
Sep 30, 2021
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Hello, I'm currently trying to insert pictures and text in a combobox on a userform. The code below is what I was able to come up with but for some reason nothing is showing up, could you guys help shed some light?

Private Sub ComboBox2_DropButtonClick()

With Me.ComboBox2.listimages

.Add , "imgl1", LoadPicture("C:\Users\rrmu135\OneDrive - Regal Beloit\Desktop\Chains\882")
.Add , "imgl2", LoadPicture("C:\Users\rrmu135\OneDrive - Regal Beloit\Desktop\Chains\1001")
.Add , "imgl3", LoadPicture("C:\Users\rrmu135\OneDrive - Regal Beloit\Desktop\Chains\1060")
.Add , "imgl4", LoadPicture("C:\Users\rrmu135\OneDrive - Regal Beloit\Desktop\Chains\1505")
.Add , "imgl5", LoadPicture("C:\Users\rrmu135\OneDrive - Regal Beloit\Desktop\Chains\8505")

End With

With Me.ComboBox2
.ImageList = ComboBox2
.ComboItems.Add , , "882", 1
.ComboItems.Add , , "1001", 2
.ComboItems.Add , , "1060", 3
.ComboItems.Add , , "1505", 4
.ComboItems.Add , , "8505", 5
End With
End Sub


-Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
It's not working because strictly speaking a ComboBox does support images, and won't help you.
Rather, what you need are two other controls that aren't in the standard toolbox setup - the ImageComboBox and the ImageList control.

You can get these controls by right clicking a blank area of the Control ToolBox and select "Additional Controls" from the context menu. You can then select the following two controls from the list:
  • Microsoft ImageComboBox Version 6.0; and
  • Microsoft ImageList Control Version 6.0
DRaw the ImageList onto the form - don't be concerned with where it goes or what it needs to look like. It will be invisible and it is going to be small square on your userform during design time. Then draw the ImageCombobox wherever on the form you like. Basically, the Imagelist is used to load and store images for later use by certain controls - like the ImageCombobox. I think your code is close, but not quite there - you'll need to load those images into the ImageList control and them transfer them across through the ListImages property (I think of the ImageComboBox), but if you do a search for these two controls (either on Google or in this forum), you should find code that will pretty much walk you through the process.

I hope that makes sense. Do let me know if you're still stuck.
 
Upvote 0
Solution
Sorry - wanting to avoid any confusion (for anyone else who stumbles across this) caused by my typo above, that should read:

It's not working because strictly speaking a ComboBox doesn't support images, and so won't help you.
 
Upvote 0

Forum statistics

Threads
1,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top