关于“列表查看器控件”_GUICtrlListView_DeleteAllItems()函数的一点疑问
今天写了个小程序,要用到列表查看器控件,却在删除所有项目是总是不能删除,经过与帮助教程的仔细对比,发现用_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
使用句柄即可
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) 老大太强了,问题已解决,谢谢! 回复 3# howacter
解决了问题请及时加注“已解决”字样。 哦,刚看见,以后注意了。汗! 活学活用,举一反三 论坛人才多,我也碰到类似问题。看样子就知道肯定是完美解决 论坛人才多,我也碰到类似问题。看样子就知道肯定是完美解决 我也遇见了相同的问题,受益匪浅啊 还是要到论坛来才有收获啊。今天在公司蹦跶了一天没把这个问题搞定。
页:
[1]