Hi there!
I've got a trouble with these things. What's going on?
1ST STEP: we have ListBox item. Let's call it ListBox1.
We're adding four values to it using AddItem method:
ListBox1.AddItem('a')
ListBox1.AddItem('b')
ListBox1.AddItem('c')
ListBox1.AddItem('d')
At this point ListIndex property is equal to -1 (because we have
clicked nothing yet),
and ListCount, of course, is equal to 4.
2ND STEP: let's click the "c" item.
Now, really, ListIndex=3 as it must be. ListCount unchanged.
3RD STEP: let's delete all of items from ListBox using
RemoveItem:
For X=1 to 4
ListBox1.RemoveItem(0)
Next X
We four times repeated deleting 0th item as far as they shifts each
time when we trying to delete one of the items. But it isn't the
problem.
Note, then HERE ListCount=0 and ListIndex=-1.
4TH STEP: let's populate ListBox with four items again, as at the 1st
step.
NOTE: after that you'll have ListIndex=3 (!) instead of -1. We have NOT
clicked
any item yet, but this property is changed.
What's this????
Why does it happens????
I appreciate any comment on this! Please, drop me a line to
andrew.panin<at>mail.ru
Thanks before, guys!