dannydy Posted July 13, 2013 Share Posted July 13, 2013 #include <GuiConstantsEx.au3> #include <File.au3> #include <Array.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> GUICreate("Automation", 300, 500) $mylist = GUICtrlCreateList("", 10, 60, 280, 100) $add = GUICtrlCreateButton("Add", 10, 35, 75, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $add Local $FileList _FileReadToArray("C:\Users\Danny Tan\Desktop\test.txt", $FileList) For $i = 1 To $FileList[0] GUICtrlSetData($mylist, $FileList[$i]) Next Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Need some helps here, How do i trying to read the data when i select it from the listview. i couldn't get it worked. Link to comment Share on other sites More sharing options...
Solution PlayHD Posted July 13, 2013 Solution Share Posted July 13, 2013 Something like this ? #include <GuiConstantsEx.au3> #include <File.au3> #include <Array.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> Local $FileList ;declare variables here, not in a loop Local $DataReadFromList $GUI = GUICreate("Automation", 300, 500) ;is good to save the window handle $mylist = GUICtrlCreateList("", 10, 60, 280, 100) $add = GUICtrlCreateButton("Add", 10, 35, 75, 20) GUISetState(@SW_SHOW,$GUI) ;;;; While 1 $msg = GUIGetMsg() Switch $msg Case $add _FileReadToArray("C:\Users\Danny Tan\Desktop\test.txt", $FileList) If @error Then ContinueLoop ;if file not found do something (else the program will generate error) For $i = 1 To $FileList[0] GUICtrlSetData($mylist, $FileList[$i]) Next Case $mylist ;if select a item from list do stuff $DataReadFromList = GUICtrlRead($mylist) MsgBox(0,0,$DataReadFromList) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd dannydy and 0xdefea7 2 My UDF : _WinShake, _WinSplitMy Apps : Google Guitar Bot, PuzzleGameDesign Gui : Interesting Tabs Design, RBox Project (abandoned), Animated Gui on Exit Link to comment Share on other sites More sharing options...
dannydy Posted July 13, 2013 Author Share Posted July 13, 2013 Many Thanks, this is really helpful...i've been headache for this:) 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