Jump to content

Cannot read text of selected list item


jackhab
 Share

Recommended Posts

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

 

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...