Function Reference


_GUICtrlListView_GetSelectedIndices

Retrieve indices of selected item(s)

#include <GuiListView.au3>
_GUICtrlListView_GetSelectedIndices ( $hWnd [, $bArray = False] )

Parameters

$hWnd Control ID/Handle to the control
$bArray [optional] Return string or Array
    True - Returns array
    False - Returns pipe "|" delimited string

Return Value

Success: Selected indices Based on $bArray:
Array - With the following format
    [0] - Number of Items in array (n)
    [1] - First item index
    [2] - Second item index
    [n] - Last item index
String - With the following format
    "0|1|2|n"
Failure: Based on $bArray
Array - With the following format
    [0] - Number of Items in array (0)
String - Empty ("")

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Selected Indices", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select multiple items
    _GUICtrlListView_SetItemSelected($idListview, 1)
    _GUICtrlListView_SetItemSelected($idListview, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Selected Indices: " & _GUICtrlListView_GetSelectedIndices($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example