Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Check item in Listview

$
0
0

I am using a function in my script below, and I want to save the items I checked into an Array. I have been able to achieve this, but lets say I now want to go back into that Window and add 2 more items to the array. I am not seeing the options checked that I previously selected.

I ran a For loop to compare the items I originally checked in the array and compared it to a list of security groups pulled down from AD, and if they match I run the function _GUICtrlListView_SetItemChecked. However, that doesn't seem to be checked the items for me. Can someone look at this function and see what I am doing wrong please?

AutoIt         
Func _AllowGroups()     _AD_Open()     Local $adGroups = _AD_GetObjectsInOU("OU=Security,OU=Groups,DC=domain,DC=com", "(objectclass=group)")     _AD_Close()     $formAllow = GUICreate("Allowed Security Groups", 280, 320)     $listAllow = GUICtrlCreateListView(" ", 15, 15, 250, 250, -1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))     _GUICtrlListView_SetColumnWidth($listAllow, 0, 232)     $btnOK = GUICtrlCreateButton("OK", 115, 280, 70, 25)     $btnCancel = GUICtrlCreateButton("Cancel", 195, 280, 70, 25)     ;_GUICtrlListView_BeginUpdate($listAllow)     If IsArray($chkAllow) Then         _ArrayDisplay($chkAllow)         _ArrayDisplay($adGroups)         For $a = 1 To $adGroups[0]             _GUICtrlListView_AddItem($listAllow, $adGroups[$a])             For $i = 1 To $chkAllow[0][0]                 If $chkAllow[$i][1] = $adGroups[$a] Then                     MsgBox(0, "", "Item to check: " & $chkAllow[$i][1] & @CR & "Row index check: " & $a)                     _GUICtrlListView_SetItemChecked($listAllow, $a, True)                     ExitLoop                 EndIf             Next         Next         MsgBox(0, '', "Loop Finished.")     Else         For $a = 1 To $adGroups[0]             _GUICtrlListView_AddItem($listAllow, $adGroups[$a])         Next     EndIf     ;_GUICtrlListView_EndUpdate($listAllow)     _setbut1()     GUISetState(@SW_SHOW, $formAllow)     ;GUISwitch($formAllow)     While 6         $msg = GUIGetMsg()         Switch $msg             Case $GUI_EVENT_CLOSE                 WinActivate("Add Application", "")                 GUIDelete($formAllow)                 ExitLoop             Case $btnCancel                 WinActivate("Add Application", "")                 GUIDelete($formAllow)                 ExitLoop             Case $btnOK                 If _checkbox_active1($listAllow) = 1 Then                     $chkAllow = _GuiCtrlListView_GetChecked($listAllow)                     _ArrayDisplay($chkAllow)                 EndIf                 WinActivate("Add Application", "")                 GUIDelete($formAllow)                 ExitLoop             Case Else                 _setbut1()         EndSwitch     WEnd EndFunc   ;==>_AllowGroups

Thanks for your time.


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>