Removes an item from a list-view control
#include <GuiListView.au3>
_GUICtrlListView_DeleteItem ( $hWnd, $iIndex )
$hWnd | Control ID/Handle to the control |
$iIndex | 0-based index of the list-view item to delete |
Success: | True. |
Failure: | False. |
_GUICtrlListView_DeleteAllItems, _GUICtrlListView_DeleteItemsSelected
#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)
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
; Pass the controlID of a native-created ListView to delete both native- and UDF-created Items
MsgBox($MB_SYSTEMMODAL, "Delete item", "Deleting UDF-created Item 12")
_GUICtrlListView_DeleteItem($idListview, 12)
MsgBox($MB_SYSTEMMODAL, "Single", "Deleting native-created Item 5")
_GUICtrlListView_DeleteItem($idListview, 5)
; 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
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
Example_UDF_Created()
Func Example_UDF_Created()
Local $aItems[10][3]
Local $hGUI = GUICreate("(UDF Created) ListView Delete All Items", 400, 300)
Local $hListView = _GUICtrlListView_Create($hGUI, "col1|col2|col3", 10, 10, 380, 280)
GUISetState(@SW_SHOW)
; 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 item", "Deleting Item 7")
; Pass the handle of a native-created ListView
_GUICtrlListView_DeleteItem($hListView, 7)
; 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_UDF_Created