ListView: Find which items in a listview are checked Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
submeg
Posts: 328
Joined: 14 Apr 2017, 20:39
Contact:

ListView: Find which items in a listview are checked

Post by submeg » 28 Jan 2024, 01:22

Hi all,

I have created a ListView, which also has checkboxes:

Code: Select all

SymptomSelectLV := SSGui.Add("ListView", "Checked r20 w450", ["Symptom","System"])
I then would like to loop through the ListView and collate the text values from column 1 ("Symptom"), only when the row is checked.

However, I am having issue splitting out those that are ticked; right now it is collecting all of the text in column 1.

Code: Select all

Loop SymptomSelectLV.GetCount()
{
	;Is the symptom checked?
	IsChecked := ControlGetChecked("SysListView321")	;need help here, unsure how to do this and for each value of A_Index
	
	If(IsChecked =1)
	{
		Value_SymptomsSelected := Value_SymptomsSelected . "," SymptomSelectLV.GetText(A_Index , 1)	;this grabs the text fine.

	}
}
Any pointers would be appreciated!
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

User avatar
flyingDman
Posts: 2838
Joined: 29 Sep 2013, 19:01

Re: ListView: Find which items in a listview are checked  Topic is solved

Post by flyingDman » 28 Jan 2024, 01:40

Example:

Code: Select all

#Requires AutoHotkey v2.0

MyGui:=Gui()
LV:=MyGui.AddListView("r5 w200 checked", ["Name"])
Loop 5
	LV.Add(,"line" A_Index)
MyGui.Show

f12::
{
RowNumber := 0
Loop
	{
	RowNumber := LV.GetNext(RowNumber, "C")
	if not RowNumber
		break
	Text := LV.GetText(RowNumber)
	MsgBox('The next selected row is #' RowNumber ', whose first field is "' Text '".')
	}
}
14.3 & 1.3.7

User avatar
submeg
Posts: 328
Joined: 14 Apr 2017, 20:39
Contact:

Re: ListView: Find which items in a listview are checked

Post by submeg » 28 Jan 2024, 03:00

Code: Select all


RowNumber := LV.GetNext(RowNumber, "C")
	if not RowNumber
		break

Code: Select all

LV.GetNext
Never would have figured that out! Thanks so much @flyingDman!
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

Post Reply

Return to “Ask for Help (v2)”