Function Reference


_GUICtrlListView_AddItem

Adds a new item to the end of the list

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

Parameters

$hWnd Control ID/Handle to the control
$sText Item text. If set to -1, the item set is set via the $LVN_GETDISPINFO notification message.
$iImage [optional] 0-based index of the item's icon in the control's image list
$iParam [optional] Application Defined data

Return Value

Success: the index of the new item.
Failure: -1

Remarks

You can not use this function to insert subitems. Use _GUICtrlListView_AddSubItem() to insert subitems.

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_AddSubItem

Example

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

Example()

Func Example()
        Local $hImage, $idListview

        ; Create GUI
        GUICreate("ListView Add Item", 400, 300)
        $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUISetState(@SW_SHOW)

        ; Load images
        $hImage = _GUIImageList_Create()
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
        _GUICtrlListView_SetImageList($idListview, $hImage, 1)

        ; Add columns
        _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)
        _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100)
        _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100)

        ; Add items
        _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
        _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
        _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

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