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?
 
rwilson032697Connect With a Mentor Commented:
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
 
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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
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
All Courses

From novice to tech pro — start learning today.