Jump to content

_GUICTRLListView_AddItem not adding items from array


Recommended Posts

Hello,

I have a script that I want to populate a ListView with security groups from my AD Structure. The problem is the list seems to populate with items, but the items are empty, so it looks like I have an empty list.

I used some code from get the type of list that I wanted, and tweaked it for my own needs.

#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <AD.au3>
#include <Array.au3>
Global $listAllow, $Btn_Start, $Btn_Exit, $msg, $ret
_AD_Open()
Local $adGroups = _AD_GetObjectsInOU("OU=Security,OU=Groups,DC=tcaps,DC=net", "(objectclass=group)")
_AD_Close()
_ArrayDisplay($adGroups)
$formAllow = GUICreate("Allowed Security Groups", 392, 322)
$listAllow = GUICtrlCreateListView("", 40, 30, 310, 149, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_REGIONAL))
_GUICtrlListView_SetColumnWidth($listAllow, 0, 100)
$Btn_Start = GUICtrlCreateButton("Start", 150, 200, 120, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
For $a = 1 To $adGroups[0]
_GUICtrlListView_AddItem($listAllow, $adGroups[$a])
Next
_setbut()
GUISetState(@SW_SHOW)
GUISwitch($formAllow)
WinActivate("Allowed Security Groups", "")
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_Start
            If _checkbox_active($listAllow) = 1 Then
                MsgBox(0, "", "at least one is checked")
            EndIf
        Case Else
            _setbut()
    EndSelect
WEnd
Exit
Func _checkbox_active($list)
    For $i = 0 To _GUICtrlListView_GetItemCount($listAllow) - 1 Step 1
        If _GUICtrlListView_GetItemChecked($listAllow, $i) = 1 Then
            Return 1
        EndIf
    Next
    Return 0
EndFunc  ;==>_checkbox_active
;
Func _setbut()
    If _checkbox_active($listAllow) Then
        If BitAND(GUICtrlGetState($Btn_Start), $GUI_DISABLE) Then
            GUICtrlSetState($Btn_Start, $GUI_ENABLE)
        EndIf
    ElseIf BitAND(GUICtrlGetState($Btn_Start), $GUI_ENABLE) Then
        GUICtrlSetState($Btn_Start, $GUI_DISABLE)
    EndIf
EndFunc  ;==>_setbut

Can anyone see why ListView_AddItem is not working?

Thanks.

Link to comment
Share on other sites

$listAllow = GUICtrlCreateListView("Column 1", 40, 30, 310, 149, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_REGIONAL))

With no column there are no data displayed

If you don't want to show column's label in header then use space instead of empty string.

Edited by Zedna
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...