I have a listview added from the designer.
I use a cursor to populate it with data:
LVDb.Clear
LVDb.TwoLinesLayout.Label.TextSize=20
LVDb.TwoLinesLayout.Label.TextColor=Colors.Yellow
LVDb.TwoLinesLayout.secondLabel.TextSize=16
LVDb.TwoLinesLayout.secondLabel.TextColor=Colors.Cyan
cursor2 = SQL2.ExecQuery(Query Text...")
For i = 0 To cursor2.RowCount - 1
cursor2.Position = i
If cursor2.Getstring2(3)<>0 Then
Log("1")
LVDb.TwoLinesLayout.Label.TextColor=Colors.Yellow
LVDb.AddTwoLines2("Text to be added...")
Else if cursor2.Getstring2(3)=0 Then
Log("2")
LVDb.TwoLinesLayout.Label.TextColor=Colors.red
LVDb.AddTwoLines2("Text to be added...")
End If
Next
cursor2.close
The code will either add the first line in yellow text or red according to the if clause, which works correctly.
However, if the first line is yellow, the second is red and the third is yellow and I remove the second line, the third line which becomes second, after the removal, gets red text, although the code runs as it should, logs "1", which in the above example means it reads the value as "<>0".
If I then remove the second line, which is red (mistakenly) and add a new second line, it is still red!!
I point out that I don't just remove the line, but clear the listview and re-run the query, populate the cursor and re-populate the listview.