Sign in to follow this  
Followers 0
TravisC

Read multiple selections of ListView

2 posts in this topic

how can i recieve multipe selected entries from a listview? GUICtrlRead seems to only return the first selected one by default.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Example:

#include <GuiListView.au3>
#include <GuiConstantsEx.au3>
#include <Array.au3> ;Only for array show

Global $aGetData

$Gui = GUICreate("Test", 320, 220)

$hListView = GUICtrlCreateListView("Items|SubItems", 10, 10, 300, 170, $LVS_REPORT, BitOR($LVS_EX_FULLROWSELECT , $WS_EX_CLIENTEDGE))

For $i = 1 To 6
    GUICtrlCreateListViewItem("Item" & $i & "|" & "SubItem" & $i, $hListView)
Next

$GetCount_Btn = GUICtrlCreateButton("Get selected", 10, 190, 80, 20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    Case $GetCount_Btn
        $aGetData = _GetEntries(_GUICtrlListView_GetSelectedIndices($hListView, True))
        _ArrayDisplay($aGetData)
    EndSwitch
WEnd

Func _GetEntries($aIndex)
    If $aIndex[0] < 1 Then Return False
    
    Local $aData[UBound($aIndex)][2]
    
    $aData[0][0] = $aIndex[0]
    
    For $i = 1 To $aIndex[0]
        $aData[$i][0] = _GUICtrlListView_GetItemText($hListView, $aIndex[$i])
        $aData[$i][1] = _GUICtrlListView_GetItemText($hListView, $aIndex[$i], 1)
    Next
    
    Return $aData
EndFunc
:) Edited by rasim

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