Filter Listview (details view)

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
I entered about 300+ items into the listview control and I would like to add a more advanced filter than what I have settled with for now. What I have it do now is the user types the text they want to search for, then click a button and it makes the items bold that match what they entered.

I would like it to remove or hide items instead so that it only shows them what they want to see.

I'll copy that part of my project to a new project in a few mins and post it here so you can see what I'm trying to do.

Thanks.
 
That's what i've recently implemented it's actually quite easy.

I'll explain and see if you understand it first, basically for each ListView Item you add into the list, first of all obviously you need to target which particular column's data you'll be filtering out, for example a column has a persons name.

So what you do is, you grab the text typed inside the filter textbox, then you grab the substring of the columns text, and you compare it together, if they're the same, then add the listview item into the list, otherwise don't add it, simple as that.
 
but I didn't think about it when I did it, but I entered all the items into the control, it doesn't load them in from a file or anything.

and also, i kinda knew how it is suppose to filter them, by comparing, but im not sure how to write the code to do it :S

If someone could download the project I posted and see if it would be pretty easy to add the code to do it, then it would really help me alot to have this filter code.

Thanks.
 
Ok i just had a look at your project, it's hard to filter it that way, because we have no way of retrieving other data to put back on the list when the filter contents changes. Filters would work really well when the data is cached into memory, i.e. it's stored into objects, or it's stored from a file or some other source in which you can dynamically obtain, but you'd obviously load the the data into an appropriate custom object, so that accessing is faster.
 
well maybe its possible to add a code that will save all the items to a file on the load event so there will be a file to load from?

if you can make it alot easy to add a filter by changing how I have it then thats fine, I just really need a filter since I have so many items in the list.
 
can anyone help me? it would really help if someone could get the first column of my listview to filter, then i can following the code as a guide to do it for the remaining columns.
 
i've been searching to find a filter to go by, but everything i find i cant figure out how to get it to work for my project.
 
Back
Top