I know there's a way to read the index of the last item added to a combo box. Does anyone remember?
thanx/good luck,
adam
Printable View
I know there's a way to read the index of the last item added to a combo box. Does anyone remember?
thanx/good luck,
adam
Combo1.ListCount - 1
John G
Sorry, but this is work only if List unsorted :((
Finally remembered:
After you've added an item to a combobox, you can look at .NewIndex to see where it was added in the combo, even if the combo is sorted.
here's some entertaining code if you want to try it out:
this form has 5 buttons and one combo with Style = 2 and Sorted = True
option Explicit
private Sub Command1_Click()
Combo1.AddItem "abc"
Combo1.ItemData(Combo1.NewIndex) = 100
MsgBox Combo1.NewIndex
End Sub
private Sub Command2_Click()
Combo1.AddItem "def"
Combo1.ItemData(Combo1.NewIndex) = 500
MsgBox Combo1.NewIndex
End Sub
private Sub Command3_Click()
Combo1.AddItem "xyz"
Combo1.ItemData(Combo1.NewIndex) = 1000
MsgBox Combo1.NewIndex
End Sub
private Sub Command4_Click()
Dim intcounter as Integer
for intcounter = 0 to Combo1.ListCount - 1
MsgBox Combo1.ItemData(intcounter)
next intcounter
End Sub
private Sub Command5_Click()
Combo1.Clear
End Sub
you'll notice that by clicking button4 you'll see the correct .ItemData for each Item in the combo even if you added the data out of alphabetical order.
thanx/good luck,
adam
Is this in reference to the adding to a bound ConboBox question?