找回密码
 加入
搜索
查看: 1371|回复: 2

[AU3基础] _GUICtrlListView_DeleteItemsSelected 使用问题

[复制链接]
发表于 2016-4-25 10:24:57 | 显示全部楼层 |阅读模式
本帖最后由 userlong 于 2016-4-25 10:26 编辑

在 GUICtrlCreateListView 列表中 要删除其中一行  使用以下语句
_GUICtrlListView_DeleteItemsSelected ($GUI_ListBox_mybx)

但是删除 经常出错。没有删除指定的那一行。。。。请高手指点
 楼主| 发表于 2016-4-25 10:25:49 | 显示全部楼层
就是 在GUICtrlCreateListView 列表中   
要删除其中一行  使用以下语句
_GUICtrlListView_DeleteItemsSelected ($GUI_ListBox_mybx)

但是删除 经常出错。没有删除指定的那一行。。。。请高手指点
发表于 2016-4-25 10:43:11 | 显示全部楼层
#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
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-29 04:20 , Processed in 0.072746 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表