函数参考


_GUICtrlListView_DeleteItemsSelected

删除所选项目

#Include <GuiListView.au3>
_GUICtrlListView_DeleteItemsSelected($hWnd)

参数

$hWnd 控件的控件ID/句柄

返回值

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

注意/说明

None.

相关

_GUICtrlListView_DeleteItem, _GUICtrlListView_DeleteAllItems

示例/演示


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

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

Example1()
Example2()
Example_UDF_Created()

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

    GUICreate("ListView Delete Items Selected", 400, 300)
    $hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    GUISetState()

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

    _GUICtrlListView_SetItemSelected($hListView, Random(0, UBound($aItems) - 1, 1))

    MsgBox(4160, "信息", "Delete Item Selected")
    ; 使用 UDF 创建的项目, 传递句柄给控件
    MsgBox(4160, "Deleted?", _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($hListView)))

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

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

    GUICreate("ListView Delete Items Selected", 400, 300)
    $hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    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)

    _GUICtrlListView_SetItemSelected($hListView, Random(0, UBound($aItems) - 1, 1))

    MsgBox(4160, "信息", "Delete Item Selected")
    ; 使用 UDF 创建的项目, 传递句柄给控件
    MsgBox(4160, "Deleted?", _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($hListView)))

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

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

    $GUI = GUICreate("(UDF Created) ListView Delete Items Selected", 400, 300)
    $hListView = _GUICtrlListView_Create($GUI, "col1|col2|col3", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    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)

    _GUICtrlListView_SetItemSelected($hListView, Random(0, UBound($aItems) - 1, 1))

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

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