Filter ListView Row Using GUI Edit Control, While keeping the Checked element Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Filter ListView Row Using GUI Edit Control, While keeping the Checked element

Post by HiSoKa » 09 Dec 2022, 17:11

Hi, I have this code, and I want to do some filtering for ListView

Code: Select all

#SingleInstance Force

Data := { Element1 : { name   : "Name1"
                    , Status : "+Check"}

        , Element2 : { name   : "Name3"
                    , Status : "-Check"}

        , Element3 : { name   : "Name4"
                    , Status : "-Check"}

		, Element4 : { name   : "Name4"
					, Status : "-Check"}

		, Element5 : { name   : "Name4"
					, Status : "+Check"}

		, Element6 : { name   : "Name4"
					, Status : "-Check"} }

Gui Add, Edit, x100 y100 w500 h21 vSearchTerm gsearch
Gui Add, ListView, w500 h525 Checked , Tag Name|Status
For k, v in Data
LV_Add(v.status,k,v.status)
LV_ModifyCol()
Gui Show, w1090 h599 , Super Archive
return

Search:
GuiControlGet, SearchTerm
LV_Delete()
For k, v in Data
{
   If (SearchTerm != "")
   {
       If InStr(k, SearchTerm)
		{
		if Data[k].Status = "+Check"
			LV_Add("+Check", k,v.Count,v.status)
		Else
			LV_Add("-Check", k,v.Count,v.status)
		}
   }
   Else
	{
		if Data[k].Status = "+Check"
			LV_Add("+Check", k,v.Count,v.status)
		Else
			LV_Add("-Check", k,v.Count,v.status)
	}
}
Return

Esc::ExitApp
Everything is working fine,
But I'm having a problem,
How can I make the checked element stay in the ListView even if them name doesn't exist in SearchTerm

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: Filter ListView Row Using GUI Edit Control, While keeping the Checked element  Topic is solved

Post by mikeyww » 09 Dec 2022, 17:51

Code: Select all

If InStr(k, SearchTerm) || Data[k].Status = "+Check"
 LV_Add("+Check", k, v.Count, v.status)

User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Re: Filter ListView Row Using GUI Edit Control, While keeping the Checked element

Post by HiSoKa » 09 Dec 2022, 17:59

Everything is working as expected now,
Thank you mikey


User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: Filter ListView Row Using GUI Edit Control, While keeping the Checked element

Post by mikeyww » 09 Dec 2022, 18:02

Good question. I have no idea, just copied some code!

User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Re: Filter ListView Row Using GUI Edit Control, While keeping the Checked element

Post by HiSoKa » 09 Dec 2022, 18:06

Sorry guys,
This is just a small part of the code I'm working on, I sent this part just to make it easier for the reader to understand it.
But I forgot to delete v.count

Post Reply

Return to “Ask for Help (v1)”