jackhab Posted February 17, 2020 Share Posted February 17, 2020 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? expandcollapse popup#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 More sharing options...
Subz Posted February 17, 2020 Share Posted February 17, 2020 (edited) Just enclose $idx with Number(), example: _DebugOut(_GUICtrlListView_GetItemTextString($idListview, Number($idx))) If you don't want to use Number(), you want to use: Local $idx = _GUICtrlListView_GetSelectionMark ($idListview) Edited February 17, 2020 by Subz Link to comment Share on other sites More sharing options...
jackhab Posted February 19, 2020 Author Share Posted February 19, 2020 On 2/17/2020 at 3:39 PM, Subz said: Just enclose $idx with Number(), example: _DebugOut(_GUICtrlListView_GetItemTextString($idListview, Number($idx))) If you don't want to use Number(), you want to use: Local $idx = _GUICtrlListView_GetSelectionMark ($idListview) It works. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now