I'm trying to create a list of files and get the name of selected file.
When I click the file name I can read the item index but text is always empty. Where is the error here?
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <Array.au3>
_DebugSetup()
AutoItSetOption("MustDeclareVars", 0)
GUICreate("Notes", 400, 300)
Local $idListview = GUICtrlCreateListView("", -1, -1, 400, 700)
GUISetState(@SW_SHOW)
_GUICtrlListView_AddColumn($idListview, "", 400)
$aFiles = _FileListToArrayRec("c:\My\OneDrive\Notes\", "*.txt", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_NOPATH)
Local $aItems[1][1]
Local $i
For $i = 0 To UBound($aFiles)-1
_ArrayAdd($aItems, $aFiles[$i], 0)
Next
_GUICtrlListView_AddArray($idListview, $aItems)
While 1
$m = GUIGetMsg()
if $m = $GUI_EVENT_PRIMARYUP Then
Local $idx = _GUICtrlListView_GetSelectedIndices($idListview)
_DebugOut($idx)
_DebugOut(_GUICtrlListView_GetItemTextString($idListview, $idx))
Exit
EndIf
Wend