_GUICtrlListView_DeleteItemsSelected 使用问题
本帖最后由 userlong 于 2016-4-25 10:26 编辑在 GUICtrlCreateListView 列表中 要删除其中一行使用以下语句
_GUICtrlListView_DeleteItemsSelected ($GUI_ListBox_mybx)
但是删除 经常出错。没有删除指定的那一行。。。。请高手指点 就是 在GUICtrlCreateListView 列表中
要删除其中一行使用以下语句
_GUICtrlListView_DeleteItemsSelected ($GUI_ListBox_mybx)
但是删除 经常出错。没有删除指定的那一行。。。。请高手指点 #include <GUIListView.au3>
#include <WindowsConstants.au3>
Global $sTexts
GUICreate('ListView', 300, 300)
$ListView1 = GUICtrlCreateListView('Column 1|Column 2|Column 3', 5, 5, 290, 240, BitOR($LVS_REPORT, $WS_BORDER), BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetColumnWidth($ListView1, 0, 80)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 100)
_GUICtrlListView_SetColumnWidth($ListView1, 2, 100)
For $i = 0 To 9
GUICtrlCreateListViewItem($i & '|项目1 - ' & $i & '|项目2 - ' & $i , $ListView1)
Next
$Button1 = GUICtrlCreateButton('读取勾选项目', 20, 260, 100, 30)
$Button2 = GUICtrlCreateButton('删除勾选项目', 180, 260, 100, 30)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case - 3
Exit
Case $Button1
Read()
Case $Button2
Del()
EndSwitch
WEnd
Func Read()
$iItemCount = _GUICtrlListView_GetItemCount($ListView1)
For $i = 0 To $iItemCount
$sItemText = _GUICtrlListView_GetItemTextString($ListView1, $i)
If _GUICtrlListView_GetItemChecked($ListView1, $i) = True Then
$sTexts &= '第:' & $i + 1 & ' 项被选中' & ' 项目文本:' & $sItemText & @CRLF
EndIf
Next
MsgBox(64, '选中项目', $sTexts)
$sTexts = ''
EndFunc ;==>Read
Func Del()
Local $z = 0
$iItemCount = _GUICtrlListView_GetItemCount($ListView1)
For $i = 0 To $iItemCount
If _GUICtrlListView_GetItemChecked($ListView1, $i - $z) = True Then
_GUICtrlListView_DeleteItem($ListView1, $i - $z)
$z += 1
EndIf
Next
EndFunc ;==>Del
页:
[1]