Jump to content

Listview Filter


JohnBailey
 Share

Recommended Posts

Suggestions, geek-slaps, improvements, corrections, etc. are MUCH appreciated and requested.

I do have a question about all this actually (see Questions section below)

This is just designed for my personal usage, but I've expanded it a bit so others may learn from it or use it too as they like. If you make adjustments that are helpful, I'd be VERY grateful to know what they are and I'll update this original post with the updates.

This is not a udf, but i guess we could make it into one.... I think haha

Updates:

  • 1.1.0 - AdvFilter updated to allow for multiple filtering on single column
  • 1.0.0 - Initial Release
Requirements:
  • 2D Array Must be setup. This is clearly (I hope) shown in the example.
Questions:
  • Should I make an initialization function that sets the LVtoFilter var and the others (see the functions) OR should I have those be parameters?
Specific Functions

See Attached (LV Filter Advanced - Functions.au3)

Example

See Attached (LV Filter - onchange expanded.au3)

Database for Example

AlondraKobayashi09469 
DanielGagnon6699
KrzysztofFrost48296681101
JonasWójciknoun1310781210
SimonFriedman8764 
VytautasAng8810
DesmondToh71902748398 
RinFriedman076
EleanorWillems11
AthanasiosWisniewski006377987110 
GraceGauthier9443283184 
JohnHansen2615113579 
DawnOrpia10
MariamKozlowski105991 
Tera0 
AthanasiosSmit887610798 
BrandenTal4392848
SamuelCarter11100108
JessicaJensen30400747544
JacobJankowski106101
TobiasScott463 
CloeKaya60
ShotaAzevedo410
HarrisGrabowski136895021
ZebulunWalsh76 
KrzysztofRusso545606
DaisyKlein428805 
Khalil503
TamásBarros67 
Visser8262 
SamuelChia
MustafaVitols1010
CloeDeboina1031103941027
JoséNilsen
ThijsDe Vries1049096437 
Jelínek03903816
DaanCosta7024 
ElifKaczmarek
YuChong5 
MustafaBarros9107 
TyroneKrumin0101
CoraimaAvraham1834 
LukasClark174 
ArchieRusso842 
Veronica5185021002
FelixNakamura745710
PetrasMacdonald7488
DelaramGreen7105971
ShotaYosef108732121510
ArnasRizzo6928645 
GabrielJansons878
MiguelKarklin1757 
LydiaTeo81020
WilbertLiepin31
FaithWilson63198059784
TyraAdrei9
EllaSegel78 
LacieMitchell3
ZeynepZielinski08209383107 
SylvesterCampbell2128
SimonMüller461 
EmilyDahan471024101
ManuelBalodis8962521294
LucasAmar41095490660
LucasWójciknoun229953
TadiumJohansen23
DawsonVitols1
DaisyRoy23 
WilbertKwiatkowski17110
ThijsTay2810 
EthanGagnon386767810
JacobBarbosa12835631
VytautasGagnon3 
ShotaLarsen0810812 
DylanShannon9410 
LazaroMancini459 
TyreekVan den Berg 
MarcSahin252486978 
Jordin813292
ShawnOng656509481
KrzysztofO'Sullivan1075
AndréOlsen02828709994 
JessicaLow95
KentaLow943510102
MojcaChia6
GabrielAvraham14121010952 
PatrickChong6171790 
Farrukh5
Florian25227179511 
WilliamMartin611104101066 
ArchieWong0057210403 
IsidroIvanova6703553
Arnas943 
GraceToh679382872 
TanaChia605269107256 
WilliamWalsh45880141012 
RosePiotrowski109377911066
JordinPospíil995220
KaitoGabai56610570 
PetuniaSegel1084961 
AlannaEglitis3 
YuKoppel2241022760 
AidanCardoso0025542
RikoFlores100
ElifVisser503 
DelaramChén109460771101 
GergoJankowski4410 
FabianCardoso10108960979
AidanDe Luca99
CelenaGarcia02
MariamNelson61040410291060 
TimothyLi8940413912
Levente9 
YukaNowak398 
JamesDabrowski8105416 
VytautasNilsen499103566
RenSchneider42874991066 
ArdentCosta5
LoganWozniak716203760 
ArdentZhou102 
ShotaPanther1509
FlorianFinaleas28
Koppel87495919310 
AlijahMorris3310 
Lindsay10097453 
Melo1210304
FábioMarino10
JanGomez0415
AthanasiosBaginski9581010043 
DiogoBerzin9291 
AthanasiosBegilins7262
LouisWisniewski658261082294
AlannaFortin9026 
KrystalBerg
YuWong63781071
JoyConti274 
DelaramKristiansen8596477446 
ShannonJanssens749 
TakumiAzevedo990272710
BjörnMartinez68199107 
KaitoTeo13134
LukeGagnon8951029126 
SophieHaugen2 
DelbarDe Jong72215556983
MarcinAndersen1529 
DylanZhang08425276
DawsonTremblay836 
GraceKatz100566 
MátéSchneider95391
JustinMalcah52052
TylerKoppel8795103416 
AidanMalcah10385 
LoganGiordano0 
EleanorTal31074091010137
SotaMartin5839 
MagnúsOchion2294128
CarinaJansons41047888416 
KarlyChen458108666755
FreyaHall70
SotaHuáng510143 
LawrenceTeo791029
CoraimaHandel6 
ChristenRomano236
Finaleas791
LydiaDeboina19
AdamLavoie57701146622
ShawnHalvorsen10252776
SotaMoshe0483 
LydiaRomano229
BramAmar0133
KaelynMartinez1 
KonstantinosMancini40616
MojcaYoung8246
ShunRoberts641073455081 
AlannaRicci769961 
BoosahDe Vries58939174746 
FabianFernandes37610773
CassieLiepin789010566337 
AidanCorreia5404
NathanClaes4486316 
ShotaNakamura6632643069 
YsabelaDe Vries590103 
JesseChia10243 
AlexanderHarris3998 
YukaKoh56136897 
LavenderBerg4391010
TyraYoung010216010539 
AlexanderFriedman94106256 
AxelDahan22658117
JackEriksen29 
EmilyPeeters44 
MitsukiMitchell1621008764
JamesJackson3
BjörnKelly7415984 
ShainaPaterson5910936472 
VioletÇelik69480
ÁdámDe Vries8465129 
FarrukhChen81656975021 
CloeRoy991292 
PawelNakamura105602 
LazaroCunha466337008
ÁdámBianchi6103 
MitsukiLuik65015
ManuelHuáng74 
MichailRizzo10372519
ZacWisniewski50012257917
PatrickKozlowski4151769613
ConnorRamirez12 
LucasBarbosa53661 
AthanasiosMelo650263170 
JanBaker57454
JoãoKatz2 
MarekLi70142966
KarlyJelínek292 
EmilyGagnon517 
CoraimaRomano5381058 
JamilaNilsen8 
CarinaPokorný0093102510724 
GavynChén30108158
Marino840536310537
SébastienClaes618401831 
AlondraGoh010586895 
MaraSchneider6104268
ChristenSmit910
KrystalHo05049623 
GraceOzolin457
ArnasKaminski31779 
FaithFernandes1003144041
TadiumOchion35 
LeventeFlores10024
AndreRicci213 
AlondraPelletier6
ArdentKowalski423956810109 
DeshawnHalvorsen819 
IoannisJacobs08410
BenjaminDemir10085205110 
MagnúsAmar10910410251710
DaikiKoh21177512 
BalázsRuicka36410 
SébastienBarbosa2910
SiennaDubois1
ShainaKlein96188 
HarrisKozlowski45 
ArchieSegel8031092 
ThijsO'Sullivan810608 
MagnúsKaczmarek5491012251040
LachlanDe Jong84514825210 
KrzysztofKalnin0022
MiuGiordano102806 
LawrenceChen696777 
NoahJansen41671247410
VayleBélanger394950168 
JanGonzalez40610511005
KrystalKrál259 
DanielOzols01030855
MoeKyle15530
MiuDahan27 
DimitrisPaterson26 
CharlotteGarcia1022
Lindsay1010421434
EllaNguyen579 
ShannonLambert934460

Example - Adding Functionality to the Filter Listview

#409333

Simplified Version(s)

#411998

(original of simplified version #411972)

ControlConstants.au3

LV_Filter___onchange_expanded.au3

LV_Filter_Advanced___Functions.au3

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Cool, Very Nice Filter! the movement is very fluent. Good idea using as the delimiter, saves space on the file size.

Thanks gesller! I really appreciate it. A friend pointed out that the "advanced filter" needs a few tweaks (ie the flickering and the ability to do if-type-statements for single columns -by that he meant like look in column one for entries with "jo" but not "hn")

Again, thanks for the feedback. It's encouraging and descriptive. If you have any suggestions or make adjustments that are helpful for others, I'll update the first post.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

I added Doubleclick to it just in case you ever decide to do anything with your filtered information..

LV_Filter___onchange_expanded.au3

P.S. I didn't invent the wheel here, :P I just added it to your existing code. S if someone sees it added I cannot remember where the code came from, but it works great!

:) Well done :) I'll update the original post.

We could even use Eltorro's LVEditInPlace and/or add a button to print and save the listview elements filtered.

A decision is a powerful thing
Link to comment
Share on other sites

Oh no, I am seeing the listbox has a limit of somewhere around 4075 lines... i modified your script to filter a csv file with 10823 lines and although it is slow and seems to randomly reposition the list it will filter the entire thing but will only show up to 4075 lines in the list. Pretty cool tho. I set the delimiter as the tab that csv adds between columns. Your filters work very well. I am trying to see if it can be modified to search between ranges of numbers in different columns of the csv.

Link to comment
Share on other sites

i modified your script to filter a csv file with 10823 lines

that is very cool :)

Your filters work very well. I am trying to see if it can be modified to search between ranges of numbers in different columns of the csv.

Thank you very much! It's awesome you're able to use it and finding bugs and adding features that we can share! As for the CSV, can we use the Excel COM UDF? I guess that wouldn't work for those without Excel though... hmm let me know what you come up with!

Oh no, I am seeing the [listview] has a limit of somewhere around 4075 line.

You might be able to use Randallc's Array2D UDF to build the listview and get around this limitation. I don't know how we could speed up the filtering... hmm I'll ponder on that.
A decision is a powerful thing
Link to comment
Share on other sites

OK, No com needed. I replaced your with from the csv tab formating and copied the csv info to a notepad and saved as a plain txt file. Will let ya know of anything else I find.. :)

I meant in reference to "I am trying to see if it can be modified to search between ranges of numbers in different columns of the csv."

However, I think I spoke to soon, because I didn't totally understand what you meant anyways. What do you mean "search between ranges of numbers in different columns of the csv"?

A decision is a powerful thing
Link to comment
Share on other sites

no worries.. LOL

OK, say like here is one row of code fro my csv:

countryname from to min max index

SomeCountryIDDD 61191 6119724 8 12 47

where the range is between these sets of numbers 61191 6119724

i want to filter for 611926, this number does not line up with either but needs to filter to the above line. I am wanting to get a filter like your contains/begins with and such to look between sets of numbers. I hope that isn't confusing..

Link to comment
Share on other sites

no worries.. LOL

OK, say like here is one row of code fro my csv:

countryname from to min max index

SomeCountryIDDD 61191 6119724 8 12 47

where the range is between these sets of numbers 61191 6119724

i want to filter for 611926, this number does not line up with either but needs to filter to the above line. I am wanting to get a filter like your contains/begins with and such to look between sets of numbers. I hope that isn't confusing..

It totally makes sense ! :) Try out the Advance Filter Section of the latest version 1.1.0. It let's select what column to search. In this instance, do two columns of each column you need and then do for one Greater Than and then the other Less Than and put the number of the most and least values in there. That should do the trick. That's actually how I'm using it right now. Let me know if I totally misunderstood what you meant though.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

Yep, it freezes up using the filters on the side, too much data.. LOL I am off to work for now but will be seeing if your filters will go in series like across the top where ya could just choose like "begins with" then next to it "greater than" and next and so on. That would be a neat addition I think.

Link to comment
Share on other sites

Yep, it freezes up using the filters on the side, too much data.. LOL I am off to work for now but will be seeing if your filters will go in series like across the top where ya could just choose like "begins with" then next to it "greater than" and next and so on. That would be a neat addition I think.

OH TOTALLY!! That would be a wonderful addition! I look forward to seeing what you develop with that! I'll update the main post when you add that. Have fun at work :)

A decision is a powerful thing
Link to comment
Share on other sites

whould it be possible to get this function as simple as possbile?? right now i have dont have a clue on how it works but i need a function like this for a script im makeing :)

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

whould it be possible to get this function as simple as possbile?? right now i have dont have a clue on how it works but i need a function like this for a script im makeing :)

of course! ;)

Could you please explain what specifically you need to be made simpler or explain what script you want it to work in so I can tailor a "simpler" version. Really the best thing I can do with this is to comment it; that way you can learn what's going on (which is the ideal situation). I'd like to make this a bit "easier" to use in general. However, if you explain to me one of those things (in the first sentence above), then it would be specific to you thus more efficient and powerful for the both of us.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

This may be a "well duh," but the Arrays are what is really being filtered and then the results are displayed in the listview control. The 2D array is similar to an invisible Listview and the Listview control itself is what is showing the filtered results.

Hope that isn't a "well duh"

A decision is a powerful thing
Link to comment
Share on other sites

Let me know if this helps out a bit. I removed the file and the include for the controlconstants.au3. I also added a function to the original Listview_Filter include.

Maybe you wanted the Fliter include file explained. I'm not sure what you are looking to be simplified. Just let me know, so someone here can help you out. :)

ListView_Filter.au3

A decision is a powerful thing
Link to comment
Share on other sites

Let me know if this helps out a bit. I removed the file and the include for the controlconstants.au3. I also added a function to the original Listview_Filter include.

Maybe you wanted the Fliter include file explained. I'm not sure what you are looking to be simplified. Just let me know, so someone here can help you out. ;)

i figured out how i think yours work and made my own :)

#Include <GuiListView.au3>

Func _LV_Filter($S_LV,$S_LV_Array2D,$LV_Collum_index,$LV_Search_String)
    _GUICtrlListViewDeleteAllItems($S_LV)
    For $x = 1 To UBound($S_LV_Array2D,1)-1
        If StringInStr($S_LV_Array2D[$x][$LV_Collum_index],$LV_Search_String) And $LV_Search_String <> "" Then
            $Data = ""
            For $y = 1 to UBound($S_LV_Array2D,2)-1
                $Data &= $S_LV_Array2D[$x][$y] & "|"
            Next
            GUICtrlCreateListViewItem($Data,$S_LV)
        EndIf
    Next
EndFunc

Func _LV_Create_2DArray($S_File,$S_Header) ;Could use number of headers here and skip the stringsplit

    ;This is the _filecountlines function
    Local $N = FileGetSize($S_File) - 1
    If @error Or $N = -1 Then Return 0
    $Num_Lines = StringLen(StringAddCR(FileRead($S_File, $N))) - $N + 1

    $Num_Header = StringSplit($S_Header,"|")
    Local $LV_Array2D[$Num_Lines+1][$Num_Header[0]+1]
    For $x = 1 To $Num_Lines
        $S_Line = FileReadLine($S_File,$x)
        $Data = StringSplit($S_Line,"|")
        For $y = 1 To $Num_Header[0]
            $LV_Array2D[$x][$y] = $Data[$y]
        Next
    Next
    Return $LV_Array2D
EndFunc
Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

i figured out how i think yours work and made my own :)

Looks rad... could you post an example?

When you do I will direct others in the original post to your simplified version.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...