BUG: ListBox - ListIndex Value Not Updated Correctly In Loop with AddItem (248226)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q248226 SYMPTOMS
Adding items in a list box using the AddItem method and including the ListIndex property in a loop gives unordered entries in the list box.
CAUSE
The problem is due to the fact that the value of ListIndex, which is being used to increment ListIndex property, does not return the correct value.
RESOLUTION
Use a memory variable to store the incrementing value instead of the ListIndex property.
Replace the Click event of the Command1 with the following:
PROCEDURE command1.Click
local lnI, nCn
with thisform
nCn=.list1.ListIndex
FOR lnI = 1 TO 50
.list1.AddItem(" "+STR(lnCounter), nCn+1, 1)
nCn = nCn + 1
lnCounter = lnCounter + 1
.list1.ListIndex=ncn
NEXT
Endwith
ENDPROC
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 10/15/2002 |
---|
Keywords: | kbBug kbCodeSnippet kbContainer kbCtrl kbDSupport KB248226 |
---|
|