How to delete records Tlistview

I am using Tlistview to store search
results, if I want to start a new
search, I want to delete the old
records in it, how to delete old records? I am using Tlistview.items.clear
but it not work, the old records still
inside, only clear Tlistview form.

Thanks & Rgds
Chiwan
chiwanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TheNeilCommented:
Try using the UpdateItems and Refresh methods for your TListView. You've cleared the items but it might not be redrawing it

The Neil
0
Liggett78Commented:
Items.Clear deletes all record that are stored in Items, so it should work, another issue if you are doing time consuming thing afterwards, e.g. immediatly after Items.Call, TListView is not updated.
0
rwilson032697Commented:
chiwan: Are you associating objects with each item in the listview? If so, you will need to free the objects yourself, Items.Clear will not do this for you. You could do it like this:

for I := 0 to listview.items.count - 1 do
  TObject(Listview.items.item[0].data).Free;
ListView.Items.Clear;

Cheers,

Raymond.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

chiwanAuthor Commented:
I have tried both methods you point out,
but not work. I am just wonder should
I distroy Tlistview before I start a
new search.

Thank& Rgds

Chiwan
0
rwilson032697Commented:
Can you calrify what you mean by "the old records still inside".

Perhaps if you showed us the code where you populate the list view it would be clearer...

Cheers,

Raymond.
0
chiwanAuthor Commented:
I make some other thing wrong, your
method works very well, thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.