Function Reference


_GUICtrlListView_SetItem

Sets some or all of a item's attributes

#include <GuiListView.au3>
_GUICtrlListView_SetItem ( $hWnd, $sText [, $iIndex = 0 [, $iSubItem = 0 [, $iImage = -1 [, $iParam = -1 [, $iIndent = -1]]]]] )

Parameters

$hWnd Control ID/Handle to the control
$sText Item text. See remark.
$iIndex [optional] The 0-based index of the item
$iSubItem [optional] 1-based index of the subitem or zero if this refers to an item
$iImage [optional] 0-base index of the item's icon in the control's image list
$iParam [optional] Value specific to the item
$iIndent [optional] Number of image widths to indent the item. A single indentation equals the width of an image.

Return Value

Success: True.
Failure: False.

Remarks

If a notification callback is needed, you have to specify $sText = -1 (LPSTR_TEXTCALLBACK).

As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended.

Related

_GUICtrlListView_GetItem, _GUICtrlListView_SetItemEx

Example

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

Example()

Func Example()
        Local $aItem, $idListview

        GUICreate("ListView Get/Set Item (v" & @AutoItVersion & ")", 400, 300)

        $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUISetState(@SW_SHOW)

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

        ; Add items
        GUICtrlCreateListViewItem("Row 0", $idListview)
        GUICtrlCreateListViewItem("Row 1", $idListview)
        GUICtrlCreateListViewItem("Row 2", $idListview)

        ; Show item 1 text
        $aItem = _GUICtrlListView_GetItem($idListview, 1)
        MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 Text: " & $aItem[3])

        ; Change item 1
        MsgBox($MB_SYSTEMMODAL, "Information", "Changing item 1")
        _GUICtrlListView_SetItem($idListview, "New Item 1", 1)

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        GUIDelete()
EndFunc   ;==>Example