Sign in to follow this  
Followers 0
lyledg

ListView Array

3 posts in this topic

#1 ·  Posted (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

:whistle:

PS: Is the only way to do this to use the _Filereadtoarray function?

Edited by lyledg

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

_GUICtrlListViewGetItemTextArray , which as I understand it that only lists the element you highlight into an array....

It puts any one item into array.

#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 by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

It puts any one item into array.

#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

Share this post


Link to post
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
Sign in to follow this  
Followers 0