找回密码
 加入
搜索
查看: 5066|回复: 9

[GUI管理] 关于“列表查看器控件”_GUICtrlListView_DeleteAllItems()函数的一点疑问

  [复制链接]
发表于 2010-9-17 18:28:39 | 显示全部楼层 |阅读模式
今天写了个小程序,要用到列表查看器控件,却在删除所有项目是总是不能删除,经过与帮助教程的仔细对比,发现用_GUICtrlListView_AddItem()和_GUICtrlListView_AddSubItem()函数添加项目后就不能删除,而用GUICtrlCreateListViewItem()函数添加却可以,不知是我的程序那里写得有问题,望各位指点。
正常的程序如下:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("测试1", 298, 328, 433, 206)
$ListView1 = GUICtrlCreateListView("Column1|Column2", 8, 8, 281, 273)
$Button1 = GUICtrlCreateButton("生成项目", 32, 288, 73, 25)
$Button2 = GUICtrlCreateButton("清除项目", 152, 288, 65, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $Button1
                        create()
                Case $Button2
                        _GUICtrlListView_DeleteAllItems($ListView1)
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func create()
        Local $i
        _GUICtrlListView_DeleteAllItems($ListView1)
        For $i=0 To 8
                GUICtrlCreateListViewItem($i&"|"&2*$i+1,$ListView1)
        Next
EndFunc
以下程序有问题:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("测试2", 298, 328, 433, 206)
$ListView1 = GUICtrlCreateListView("Column1|Column2", 8, 8, 281, 273)
$Button1 = GUICtrlCreateButton("生成项目", 32, 288, 73, 25)
$Button2 = GUICtrlCreateButton("清除项目", 152, 288, 65, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $Button1
                        create()
                Case $Button2
                        _GUICtrlListView_DeleteAllItems($ListView1)
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func create()
        Local $i
        _GUICtrlListView_DeleteAllItems($ListView1)
        For $i=0 To 8                
                _GUICtrlListView_AddItem($ListView1,$i)
                _GUICtrlListView_AddSubItem($ListView1,$i,2*$i+1,1)
        Next
EndFunc

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-9-17 18:37:35 | 显示全部楼层
使用句柄即可
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
 楼主| 发表于 2010-9-17 18:40:55 | 显示全部楼层
老大太强了,问题已解决,谢谢!
发表于 2010-9-18 02:14:01 | 显示全部楼层
回复 3# howacter


        解决了问题请及时加注“已解决”字样。
 楼主| 发表于 2010-9-19 16:57:43 | 显示全部楼层
哦,刚看见,以后注意了。汗!
发表于 2012-7-20 10:49:55 | 显示全部楼层
活学活用,举一反三
发表于 2012-10-5 16:54:39 | 显示全部楼层
论坛人才多,我也碰到类似问题。看样子就知道肯定是完美解决
发表于 2012-10-5 16:54:42 | 显示全部楼层
论坛人才多,我也碰到类似问题。看样子就知道肯定是完美解决
发表于 2013-3-13 14:49:35 | 显示全部楼层
我也遇见了相同的问题,受益匪浅啊
发表于 2013-5-16 22:23:33 | 显示全部楼层
还是要到论坛来才有收获啊。  今天在公司蹦跶了一天没把这个问题搞定。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-13 11:29 , Processed in 0.084957 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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