本帖最后由 blue_dvd 于 2012-11-10 20:15 编辑
今天发现一个问题?#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
GUICreate("ListView Click Item", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268, "", $LVS_EX_FULLROWSELECT+$LVS_EX_CHECKBOXES)
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 200)
_GUICtrlListView_InsertColumn($hListView, 0, "Column 2", 150)
GUISetState()
Local $LV_Item[1], $CheckNum = 0
For $i = 1 To 20
_ArrayAdd($LV_Item, GUICtrlCreateListViewItem("Row "&$i&": Col 1", $hListView))
MsgBox(0,"读取$LV_Item",$LV_Item[$i])
Next
$LV_Item[0] = UBound($LV_Item)-1
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
运行值从4开始,为什么呢?
改一下#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
GUICreate("ListView Click Item", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268, "", $LVS_EX_FULLROWSELECT+$LVS_EX_CHECKBOXES)
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 200)
_GUICtrlListView_InsertColumn($hListView, 0, "Column 2", 150)
GUISetState()
Local $LV_Item[1], $CheckNum = 0
For $i = 1 To 20
_ArrayAdd($LV_Item, _GUICtrlListView_AddItem($hListView, "Row "&$i&": Col 1",$i))
MsgBox(0,"读取$LV_Item",$LV_Item[$i])
Next
$LV_Item[0] = UBound($LV_Item)-1
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
值却是0开始
GUICtrlCreateListViewItem() 可以返回控件Id,_GUICtrlListView_AddItem()应该返回不了ID,那有没有专门的函数读取其ID呢?
懂的赐教一下!谢谢了!
3楼annybody正解! |