Skip to content

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 item
  • List - Collection of list items
  • ListCount - Number of list items
  • ListIndex - Index of currently selected item
  • BackColor - Background color
  • ForeColor - Foreground color
  • Enabled - Whether control is enabled
  • Font - Font settings
  • Visible - Whether visible
  • ImageList - Associated image list control
  • Images - Collection of images associated with items
  • IndentLevel - Indentation level
  • ItemData - Numeric data associated with items
  • SelImage - Image index when selected
  • Image - Default image index

Events

  • Change - Triggered when selection changes
  • Click - Triggered when control is clicked
  • DblClick - Triggered when control is double-clicked
  • DropDown - Triggered when list drops down
  • GotFocus - Triggered when control receives focus
  • KeyDown - Triggered when keyboard key is pressed
  • KeyPress - Triggered during keyboard key press
  • KeyUp - Triggered when keyboard key is released
  • LostFocus - Triggered when control loses focus
  • MouseDown - Triggered when mouse button is pressed
  • MouseMove - Triggered when mouse moves
  • MouseUp - Triggered when mouse button is released
  • Scroll - Triggered when list is scrolled
  • CloseUp - 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

VB6 and LOGO copyright of Microsoft Corporation