Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone have an example of a working Image ComboBox or ListBox

Status
Not open for further replies.

denchyb

Programmer
Oct 19, 1999
2
US
I am try to populate the combo box with data for the database. However, the objDepartment.ItemData(objDepartment.NewIndex) only accepts an integer. In this case, my id(key)is a string.<br>
I believe a Image ComboBox will solve the problem or a dynamic array that can store the the additem and id of the regular combo box. I am not very familiar with arrays.<br>
<br>
If anyone can give me any suggestions. I would really appreciate it.
 
VB6 :<br>
<br>
<br>
Option Explicit<br>
<br>
Dim lblItem As Label<br>
Dim lblPrice As Label<br>
<br>
Dim WithEvents txtPrice As TextBox<br>
<br>
a ImageList and a ImagCombo<br>
<br>
Private Sub Form_Load()<br>
Dim cbiVar As ComboItem<br>
<br>
'The following line may be necessary to locate the pictures<br>
'ChDir App.Path<br>
<br>
'Create Labels and TextBox<br>
Set lblItem = Me.Controls.Add(&quot;vb.label&quot;, &quot;lblItem&quot;, Me)<br>
Set lblPrice = Me.Controls.Add(&quot;vb.label&quot;, &quot;lblPrice&quot;, Me)<br>
Set txtPrice = Me.Controls.Add(&quot;vb.textbox&quot;, &quot;txtPrice&quot;, Me)<br>
<br>
lblItem.Caption = &quot;Item&quot;<br>
lblItem.Visible = True<br>
lblItem.TabIndex = 0<br>
lblPrice.Caption = &quot;Price&quot;<br>
lblPrice.Visible = True<br>
lblPrice.TabIndex = 2<br>
txtPrice.Text = &quot;&quot;<br>
txtPrice.Visible = True<br>
txtPrice.TabIndex = 3<br>
txtPrice.Locked = True<br>
<br>
'Load Images into ImageList<br>
Me.imlImages.ListImages.Add , &quot;CPU&quot;, LoadPicture(&quot;pc03.ico&quot;)<br>
Me.imlImages.ListImages.Add , &quot;MONITOR&quot;, LoadPicture(&quot;monitr01.ico&quot;)<br>
Me.imlImages.ListImages.Add , &quot;KEYBOARD&quot;, LoadPicture(&quot;keybrd02.ico&quot;)<br>
Me.imlImages.ListImages.Add , &quot;MOUSE&quot;, LoadPicture(&quot;mouse02.ico&quot;)<br>
<br>
'Set up ImageCombo<br>
Me.icbMain.Text = &quot;&quot;<br>
Set Me.icbMain.ImageList = Me.imlImages<br>
<br>
'Load ComboItems into icbMain. Put the price into _<br>
the Tag property<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;P200&quot;, &quot;Pentium 200 MMX&quot;, &quot;CPU&quot;)<br>
cbiVar.Tag = 1200<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;P233&quot;, &quot;Pentium 233 MMX&quot;, &quot;CPU&quot;)<br>
cbiVar.Tag = 1400<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;P300&quot;, &quot;Pentium II 300&quot;, &quot;CPU&quot;)<br>
cbiVar.Tag = 1600<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;P333&quot;, &quot;Pentium II 333&quot;, &quot;CPU&quot;)<br>
cbiVar.Tag = 1800<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;P360&quot;, &quot;Pentium II 360&quot;, &quot;CPU&quot;)<br>
cbiVar.Tag = 2000<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;P400&quot;, &quot;Pentium II 400&quot;, &quot;CPU&quot;)<br>
cbiVar.Tag = 2200<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;M14&quot;, &quot;14 Inch Monitor&quot;, &quot;MONITOR&quot;)<br>
cbiVar.Tag = 250<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;M17&quot;, &quot;17 Inch Monitor&quot;, &quot;MONITOR&quot;)<br>
cbiVar.Tag = 400<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;M19&quot;, &quot;19 Inch Monitor&quot;, &quot;MONITOR&quot;)<br>
cbiVar.Tag = 800<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;K102&quot;, &quot;102 Key Keyboard&quot;, &quot;KEYBOARD&quot;)<br>
cbiVar.Tag = 29.95<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;K104&quot;, &quot;104 Key Keyboard&quot;, &quot;KEYBOARD&quot;)<br>
cbiVar.Tag = 39.95<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;K104E&quot;, &quot;104 Key Ergonomic Keyboard&quot;, &quot;KEYBOARD&quot;)<br>
cbiVar.Tag = 69<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;M2&quot;, &quot;2 Button Mouse&quot;, &quot;MOUSE&quot;)<br>
cbiVar.Tag = 60<br>
Set cbiVar = Me.icbMain.ComboItems.Add(, &quot;M3&quot;, &quot;3 Button Mouse&quot;, &quot;MOUSE&quot;)<br>
cbiVar.Tag = 75<br>
End Sub<br>
<br>
<br>
Eric De Decker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top