How to filter data inside listview
Hi all i got a huge list data inside my listview as shown in pic. One of the column name is URL. I want to filter the list to those url that this pattern exist on the their url .The bold parts are dynamic and is changeing .:
for example
Code:
http://localhost/AlbumSongs.asp?AlbumId=1734&Album=for life&Singer=Andy&SingerID=1383
or
http://localhost/player/player.asp?id=16411
http://i5.photobucket.com/albums/y18...viewfilter.jpg
I be happy if an expert show me how i can achive this easily and fast.Thanks
Re: How to filter data inside listview
You will have to do a (sub)string match on each item in the listview, in a for loop
use the InString function to check for a match.
If you are going to delete non-matching items, then loop from the last item backwards.
Not very fast, it would be quicker if the text was in a string array, and
you copy the matched items into a listview.
Re: How to filter data inside listview
The bolded examples don't look like the data in the listview but I'll assume that they are below the displayed data. In any case one way of doing it would be to add three hidden columns for the AlbumId, Album and Singer and then do a sort and or find on them instead of the URL column. If you are interested in doing it that way I can post some code from Aaron Young that will make the columns invisible and non-expandable to the user.
Re: How to filter data inside listview
Quote:
Originally Posted by donW
You will have to do a (sub)string match on each item in the listview, in a for loop
use the InString function to check for a match.
If you are going to delete non-matching items, then loop from the last item backwards.
Not very fast, it would be quicker if the text was in a string array, and
you copy the matched items into a listview.
Many thanks for u reply. could u show me how i can do (sub)string match on each item in the listview, in a for loop as i am not good in dealing with listview.I just want put the matched ones into another lisview or just save it in to text file. could u tell me what u mean by text beaing as string array ... ? do u mean the data was in textbox or ? I be happy if u help here.Thanks
Re: How to filter data inside listview
I am just guessing, but I think to reading and string comparing each text item from a listview would be slower than the same from a string array.
with a listview:
lv is your listview
for x = 1 to lv.listitems.count
if instring ( lv.listitem(x).text, "string to match") > 0 then
lv2.listitems.add ,,lv.listitem(x).text
next x
you may need to do multiple partial string match checks if you are trying to match a number of parts of a string.
Also look a the Split function which may be of use to break up your string if it has
known delimiter characters.
Re: How to filter data inside listview
Thank u guy for u reply .Do u guys think if i put my data in textbox or text file filtering them would be easier ? Since i can do that . If that is easy then i be happy if u guys show me how to filte urls from eaither .txt file or textbox?
Re: How to filter data inside listview
Quote:
Originally Posted by tony007
Thank u guy for u reply .Do u guys think if i put my data in textbox or text file filtering them would be easier ? Since i can do that . If that is easy then i be happy if u guys show me how to filte urls from eaither .txt file or textbox?
Either of those ways would be less efficient than having the data in the listview.
Re: How to filter data inside listview
donW could u tell me how to run your code ?what controle i do need and ..Thanks
Re: How to filter data inside listview
Quote:
Originally Posted by MartinLiss
Either of those ways would be less efficient than having the data in the listview.
Martin thank u nice info. Could u tell how about mysql if i some how get the data to mysql . Currently the data is in .csv file . Is there an easy way to send it to mysql db if that makes live easy since the size of url records are huge and i need to be filtred .Thanks
Re: How to filter data inside listview
Sorry, I've never used it.