Function Reference


_GUICtrlListView_MapIndexToID

Maps an index to an item ID

#include <GuiListView.au3>
_GUICtrlListView_MapIndexToID ( $hWnd, $iIndex )

Parameters

$hWnd Control ID/Handle to the control
$iIndex 0-based index of an item

Return Value

Returns the ID of the item.

Remarks

ListView controls internally track items by index.
This can present problems because indexes can change during the control's lifetime.

The ListView control can tag an item with an ID when the item is created.
You can use this ID to guarantee uniqueness during the lifetime of the control.

Related

_GUICtrlListView_MapIDToIndex

Example

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

Example()

Func Example()
        Local $iID, $idListview

        GUICreate("ListView Map Index  To ID", 400, 300)
        $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUISetState(@SW_SHOW)

        ; Add column
        _GUICtrlListView_AddColumn($idListview, "Items", 100)

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

        ; Show ID for item 2
        $iID = _GUICtrlListView_MapIndexToID($idListview, 1)
        MsgBox($MB_SYSTEMMODAL, "Information", "Index to ID: " & $iID)
        MsgBox($MB_SYSTEMMODAL, "Information", "ID to Index: " & _GUICtrlListView_MapIDToIndex($idListview, $iID))

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