函数参考


_GUICtrlListView_DeleteItem

删除项目

#Include <GuiListView.au3>
_GUICtrlListView_DeleteItem($hWnd, $iIndex)

参数

$hWnd 控件的控件ID/句柄
$iIndex 被删除项目的 0 基索引

返回值

成功: 返回 True
失败: 返回 False

注意/说明

None.

相关

_GUICtrlListView_DeleteAllItems, _GUICtrlListView_DeleteItemsSelected

示例/演示


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

$Debug_LV = False ; 检查传递给 ListView 函数的类名, 设置为真并使用另一控件的句柄可以看出它是否有效

Example1()
Example_UDF_Created()

Func Example1()
    Local $hListView

    GUICreate("ListView Delete Item", 400, 300)
    $hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUISetState()

    ; 加载三列
    For $iI = 0 To 9
        GUICtrlCreateListViewItem("Item " & $iI & "|Item " & $iI & "-1|Item " & $iI & "-2", $hListView)
    Next

    MsgBox(4160, "信息", "Delete Item")
    ; 用内置函数创建项目, 传递控件 ID
    MsgBox(4160, "Deleted?", _GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView), 1))

    ; 循环直到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example1

Func Example_UDF_Created()
    Local $GUI, $aItems[10][3], $hListView

    $GUI = GUICreate("(UDF Created) ListView Delete Item", 400, 300)
    $hListView = _GUICtrlListView_Create($GUI, "col1|col2|col3", 2, 2, 394, 268)
    GUISetState()

    ; 加载三列
    For $iI = 0 To UBound($aItems) - 1
        $aItems[$iI][0] = "Item " & $iI
        $aItems[$iI][1] = "Item " & $iI & "-1"
        $aItems[$iI][2] = "Item " & $iI & "-2"
    Next

    _GUICtrlListView_AddArray($hListView, $aItems)

    MsgBox(4160, "信息", "Delete Item")
    ; 这已经是个句柄
    MsgBox(4160, "Deleted?", _GUICtrlListView_DeleteItem($hListView, 1))

    ; 循环直到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_UDF_Created