|
-
July 30th, 2001, 06:20 PM
#1
Index of last Item added to a Combo Box
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
thanx/good luck
-
July 30th, 2001, 07:44 PM
#2
Re: Index of last Item added to a Combo Box
Combo1.ListCount - 1
John G
-
July 30th, 2001, 08:14 PM
#3
Re: Index of last Item added to a Combo Box
Sorry, but this is work only if List unsorted (
Andy Tower
-
August 2nd, 2001, 12:23 PM
#4
Re: Index of last Item added to a Combo Box
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
thanx/good luck
-
August 2nd, 2001, 12:46 PM
#5
Re: Index of last Item added to a Combo Box
Is this in reference to the adding to a bound ConboBox question?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|