Function Reference


_GUICtrlListView_SetItemSelected

Sets whether the item is selected

#include <GuiListView.au3>
_GUICtrlListView_SetItemSelected ( $hWnd, $iIndex [, $bSelected = True [, $bFocused = False]] )

Parameters

$hWnd Control ID/Handle to the control
$iIndex 0-based index of the item, -1 to set selected state of all items
$bSelected [optional] If True the item(s) are selected, otherwise not.
$bFocused [optional] If True the item has focus, otherwise not.

Return Value

Success: True.
Failure: False.

Remarks

If the listview is using the control style $LVS_SINGLESEL, setting $iIndex to -1 will not select all of the items.

Related

_GUICtrlListView_GetItemSelected

Example

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

Example()

Func Example()
        GUICreate("ListView Get/Set Item Selected (v" & @AutoItVersion & ")", 400, 300)
        Local $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUISetState(@SW_SHOW)

        ; Set ANSI format
;~     _GUICtrlListView_SetUnicodeFormat($idListview, False)

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

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

        ; Select item 1
        _GUICtrlListView_SetItemSelected($idListview, 1)
        MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 Selected: " & _GUICtrlListView_GetItemSelected($idListview, 1))

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