Article ID: 186896
Article Last Modified on 7/13/2004
Private Sub Command1_Click()
'Add a new ComboItem to the ImageCombo
Dim sItemKey As String
Dim sText As String
Dim i As Integer
Static iCount As Integer
sText = InputBox("Enter Text for new ComboItem")
If Len(sText) > 0 Then
iCount = iCount + 1
sItemKey = "I00" & Str(iCount)
'If you don't have a selected image you will not see an
'image when the item is selected.
'Get the image you want to use.
i = SelectPic
ImageCombo1.ComboItems.Add , sItemKey, sText, _
i, i, Val(Text1.Text)
'Make the ComboItem you just added the selected item.
ImageCombo1.SelectedItem = ImageCombo1.ComboItems(sItemKey)
'Make sure the Remove button is enabled.
Command2.Enabled = True
End If
End Sub
Private Sub Command2_Click()
'Remove the selected ComboItem.
Dim i As Integer
i = ImageCombo1.SelectedItem.Index
ImageCombo1.ComboItems.Remove i
'Make the first ComboItem the select item if there is one.
If ImageCombo1.ComboItems.Count > 0 Then
ImageCombo1.SelectedItem = ImageCombo1.ComboItems(1)
Else
ImageCombo1.Text = ""
ImageCombo1.Refresh 'clear the image
Command2.Enabled = False
End If
End Sub
Private Sub Form_Load()
ImageCombo1.ImageList = ImageList1
Command1.Caption = "Add"
Command2.Caption = "Remove"
Option1.Caption = ""
Option2.Caption = ""
Option3.Caption = ""
Option4.Caption = ""
Option1.Picture = ImageList1.ListImages(1).Picture
Option2.Picture = ImageList1.ListImages(2).Picture
Option3.Picture = ImageList1.ListImages(3).Picture
Option4.Picture = ImageList1.ListImages(4).Picture
Text1.Text = 1
ImageCombo1.Text = ""
Command2.Enabled = False
Option1.Value = True
End Sub
Private Function SelectPic() As Integer
'Find out which OptionButton is selected and use that
'image in the ImageCombo that you are adding.
Dim i As Integer
Dim b As Boolean
b = True
Select Case b
Case Option1.Value
i = 1
Case Option2.Value
i = 2
Case Option3.Value
i = 3
Case Option4.Value
i = 4
End Select
SelectPic = i
End Function
Additional query words: kbDSupport kbDSD kbCtrl kbUsage kbVBp600 kbVBp
Keywords: kbhowto KB186896