Board index » delphi » Virtual ListView Problem: Selected Item can not display correctly when i delete items before it

Virtual ListView Problem: Selected Item can not display correctly when i delete items before it

    i have a ListView whose OwnerData is True, and i prepared a list for it,
giving it the data in the OnData event.
    Now i met a very strange problem: when i delete an item before the
selected item(DeletedItem.ItemIndex < Selected.ItemIndex), the selected Item
remains its position on the screen, but point to original data, e.g. if i
have 10 Items in the list, and Items[5] is selected, now i delete Items[0]
in my list(of course, i should set ListView.Items. Count to Count -1), in
the screen, the 5th line is painted with blue blackground, and if i read the
Data of the selected Item, it points to the correct data(the 4th Item after
deletion). Please help me. thanks.
 

Re:Virtual ListView Problem: Selected Item can not display correctly when i delete items before it


After the delete operation,  call ListView.UpdateItems.
This should help I think.

Regards

Other Threads