# Function Reference

# _GUICtrlListView_DeleteAllItems

Removes all items from a list-view control

#include <GuiListView.au3>
_GUICtrlListView_DeleteAllItems ( $hWnd )

## Parameters

$hWnd | Control ID/Handle to the control

## Return Value

Success: | True.
Failure: | False.

## Remarks

Deleting all items from a native-created ListView can take some time - it is recommended to enclose this command in a _GUICtrlListView_Begin/EndUpdate pairing if this is the case.

## Related

_GUICtrlListView_DeleteItem, _GUICtrlListView_DeleteItemsSelected

## Example

### Example 1

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

    Example()

    Func Example()
        GUICreate("ListView Item Deletion", 400, 500)
        Local $idListview = GUICtrlCreateListView("Col 1               |Col 2      |Col 3      ", 10, 10, 380, 480, $LVS_SHOWSELALWAYS)

        ; Display the GUI.
        GUISetState(@SW_SHOW)

        For $i = 0 To 9
            GUICtrlCreateListViewItem("Native Item " & $i & "|Item " & $i & "-1|Item " & $i & "-2", $idListview)
        Next
        For $i = 10 To 20
            _GUICtrlListView_AddItem($idListview, "UDF Item " & $i, -1, 1000 + $i)
            _GUICtrlListView_AddSubItem($idListview, $i, "Item " & $i & "-1", 1)
            _GUICtrlListView_AddSubItem($idListview, $i, "Item " & $i & "-2", 2)
        Next

        MsgBox($MB_SYSTEMMODAL, "Delete all", "Deleting both native and UDF Items")

        ; Pass the controlID of a native-created ListView
        _GUICtrlListView_DeleteAllItems($idListview)

        ; Loop until the user exits
        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    ExitLoop

            EndSwitch
        WEnd

        ; Delete the previous GUI and all controls.
        GUIDelete()
    EndFunc   ;==>Example

### Example 2

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

    Example() ; A ListView control created with the ListView UDF.

    Func Example()
        Local $aItems[10][3]

        Local $hGUI = GUICreate("(UDF Created) ListView Delete All Items (v" & @AutoItVersion & ")", 400, 300)
        Local $hListView = _GUICtrlListView_Create($hGUI, "col1|col2|col3", 10, 10, 380, 280)

        ; Display the GUI.
        GUISetState(@SW_SHOW)

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

        ; 3 column load
        For $i = 0 To UBound($aItems) - 1
            $aItems[$i][0] = "Item " & $i
            $aItems[$i][1] = "Item " & $i & "-1"
            $aItems[$i][2] = "Item " & $i & "-2"
        Next

        _GUICtrlListView_AddArray($hListView, $aItems)

        MsgBox($MB_SYSTEMMODAL, "Delete all", "Delete all items")

        ; Pass the handle of a UDF-created ListView
        _GUICtrlListView_DeleteAllItems($hListView)

        ; Loop until the user exits
        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    ExitLoop

            EndSwitch
        WEnd

        ; Delete the previous GUI and all controls.
        GUIDelete()
    EndFunc   ;==>Example