ImageCombo Control (VBCCRImageCombo)
The ImageCombo control is a combo box control with images, which can display an image next to each list item. This control typically works in conjunction with the ImageList control to create more intuitive dropdown lists.
Properties
Basic Properties
Text
- Text of currently selected itemList
- Collection of list itemsListCount
- Number of list itemsListIndex
- Index of currently selected itemBackColor
- Background colorForeColor
- Foreground colorEnabled
- Whether control is enabledFont
- Font settingsVisible
- Whether visible
Image-related Properties
ImageList
- Associated image list controlImages
- Collection of images associated with itemsIndentLevel
- Indentation levelItemData
- Numeric data associated with itemsSelImage
- Image index when selectedImage
- Default image index
Events
Change
- Triggered when selection changesClick
- Triggered when control is clickedDblClick
- Triggered when control is double-clickedDropDown
- Triggered when list drops downGotFocus
- Triggered when control receives focusKeyDown
- Triggered when keyboard key is pressedKeyPress
- Triggered during keyboard key pressKeyUp
- Triggered when keyboard key is releasedLostFocus
- Triggered when control loses focusMouseDown
- Triggered when mouse button is pressedMouseMove
- Triggered when mouse movesMouseUp
- Triggered when mouse button is releasedScroll
- Triggered when list is scrolledCloseUp
- Triggered when dropdown list closes
Code Examples
Basic Usage
vb
Private Sub InitImageCombo()
' Set image list
Set ImageCombo1.ImageList = ImageList1
' Add items
With ImageCombo1
.AddItem "Documents"
.ListImages(0).Picture = 1 ' Document icon
.AddItem "Pictures"
.ListImages(1).Picture = 2 ' Picture icon
.AddItem "Music"
.ListImages(2).Picture = 3 ' Music icon
End With
End Sub
Tree Menu Implementation
vb
Private Type MenuItem
Text As String
ImageIndex As Long
SelImageIndex As Long
Level As Long
Tag As String
SubItems() As Long ' Array of sub-item indices
SubItemCount As Long
ParentIndex As Long
End Type
Private Type MenuManager
Items() As MenuItem
Count As Long
ImageList As ImageList
End Type
Private Menu As MenuManager
Private Sub InitMenuManager()
With Menu
ReDim .Items(1 To 100)
.Count = 0
Set .ImageList = ImageList1
End With
End Sub
Private Function AddMenuItem(ByVal Text As String, _
ByVal ImageIndex As Long, _
Optional ByVal SelImageIndex As Long = -1, _
Optional ByVal Level As Long = 0, _
Optional ByVal ParentIndex As Long = 0) As Long