Page 1 of 1

Help with uncheck items in ListView

Posted: 01 Jan 2019, 04:51
by Tomer
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



Re: Help with uncheck items in ListView

Posted: 01 Jan 2019, 07:02
by just me
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

Re: Help with uncheck items in ListView

Posted: 02 Jan 2019, 00:11
by Tomer
Ty just me!