lyledg Posted July 17, 2007 Share Posted July 17, 2007 (edited) Hi guys Could someone possibly give me a small working example of how to read ALL the contents of a list view control , with 3 columns to an array, please? I have looked in the help files and in the forum, but only found _GUICtrlListViewGetItemTextArray , which as I understand it that only lists the element you highlight into an array.... Is there a similar function that I am not aware of? Many thanks PS: Is the only way to do this to use the _Filereadtoarray function? Edited July 17, 2007 by lyledg Link to comment Share on other sites More sharing options...
Siao Posted July 17, 2007 Share Posted July 17, 2007 (edited) _GUICtrlListViewGetItemTextArray , which as I understand it that only lists the element you highlight into an array....It puts any one item into array. expandcollapse popup#include <Array.au3> ;for _ArrayDisplay #include <GUIConstants.au3> #Include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 415, 300, 296, 238) $ListView1 = GUICtrlCreateListView("1|2|3", 64, 36, 297, 201) $ListView1_0 = GUICtrlCreateListViewItem("11|12|13", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("21|22|23", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("31|32|33", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("41|42|43", $ListView1) $Button1 = GUICtrlCreateButton("Get items", 144, 256, 129, 29, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 getLVitems() EndSwitch WEnd Func getLVitems() $itmcount = _GUICtrlListViewGetItemCount( $ListView1 ) $colcount = _GUICtrlListViewGetSubItemsCount( $ListView1 ) Global $aLV[$itmcount][$colcount] For $i = 0 To $itmcount-1 $aRow = _GUICtrlListViewGetItemTextArray( $ListView1, $i ) For $j = 1 To $aRow[0] $aLV[$i][$j-1] = $aRow[$j] Next Next _ArrayDisplay($aLV) EndFunc Edited July 17, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
lyledg Posted July 17, 2007 Author Share Posted July 17, 2007 It puts any one item into array. expandcollapse popup#include <Array.au3> ;for _ArrayDisplay #include <GUIConstants.au3> #Include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 415, 300, 296, 238) $ListView1 = GUICtrlCreateListView("1|2|3", 64, 36, 297, 201) $ListView1_0 = GUICtrlCreateListViewItem("11|12|13", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("21|22|23", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("31|32|33", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("41|42|43", $ListView1) $Button1 = GUICtrlCreateButton("Get items", 144, 256, 129, 29, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 getLVitems() EndSwitch WEnd Func getLVitems() $itmcount = _GUICtrlListViewGetItemCount( $ListView1 ) $colcount = _GUICtrlListViewGetSubItemsCount( $ListView1 ) Global $aLV[$itmcount][$colcount] For $i = 0 To $itmcount-1 $aRow = _GUICtrlListViewGetItemTextArray( $ListView1, $i ) For $j = 1 To $aRow[0] $aLV[$i][$j-1] = $aRow[$j] Next Next _ArrayDisplay($aLV) EndFunc Thank you so much Siao, that has helped me a lot! Cheers 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