Help with uncheck items in ListView

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Tomer
Posts: 282
Joined: 21 Aug 2016, 05:11

Help with uncheck items in ListView

01 Jan 2019, 04:51

hey

im trying to uncheck row2, row3, row4 & row5 only when row1 is checked
what im doing wrong ?

tnx in advance

Code: Select all

Gui Add, ListView, Checked  gTest, Name
Gui show
loop, 5
LV_Add("","Row" a_index)
return

test:
FocusedRowNumber := LV_GetNext()  ; Find the focused row.
LV_GetText(Name, FocusedRowNumber, 1) ; Get the text of the 1st field focused row.

if FocusedRowNumber = Row1 ; if Row1 is chekced
	Loop, 4
{ 
    MyIndex :=  A_Index+1
    LV_Modify(MyIndex, "-check") ; uncheck row2, row3, row4 & row5 (if they were checked)
}  
return


just me
Posts: 6366
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Help with uncheck items in ListView

01 Jan 2019, 07:02

Happy new year!

Code: Select all

#NoEnv
SetBatchLines, -1
Gui, Add, ListView, w400 AltSubmit Checked vLV gTest, Name
Loop, 5
   LV_Add("", "Row" . A_Index)
Gui, Show, , LV Test
Return

Test:
Critical ; because of AltSubmit
; (A_GuiEvent == "I") -> item changed, InStr(ErrorLevel, "C", 1) -> item has been checked
If (A_GuiEvent == "I") && InStr(ErrorLevel, "C", 1) {
   GuiControl, -g, LV ; remove the g-label
   ; (A_EventInfo = 1) -> it's the first item
   If (A_EventInfo = 1) {
      Loop, 4
         LV_Modify(A_Index + 1, "-Check") ; uncheck row2, row3, row4 & row5 (if they were checked)
   }
   ; (A_EventInfo < 6) -> item 2 - 5, (LV_GetNext(0, "C") = 1) -> the first item is checked
   Else If (A_EventInfo < 6) && (LV_GetNext(0, "C") = 1)
      LV_Modify(A_EventInfo, "-Check")
   GuiControl, +g%A_ThisLabel%, LV ; re-add the g-label
}
Return

GuiClose:
ExitApp

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], casperharkin, CuriousLy, Google [Bot], TAC109 and 160 guests