你的代码我无法测试,实在不好弄,抱歉啊!
只好做了一个简单的 ListView 项目数据更新,希望对你有帮助。#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $sText
AdlibRegister('_Random', 1000)
$Form1 = GUICreate("Form1", 380, 350)
$ListView1 = GUICtrlCreateListView("项目名称|每隔 1 秒 随机取值", 5, 5, 370, 280)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 170)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 170)
;GUICtrlCreateListViewItem('abc|123', $ListView1)
;GUICtrlCreateListViewItem('def|100', $ListView1)
;GUICtrlCreateListViewItem('ghi|321', $ListView1)
GUICtrlCreateLabel("项目名称:", 10, 310, 80, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 90, 310, 200, 21)
$But1 = GUICtrlCreateButton("添加", 290, 308, 75, 25, $WS_GROUP)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case - 3
Exit
Case $But1
$sItemName = GUICtrlRead($Input1)
If $sItemName <> '' Then
If Eval('!' & $sItemName) = '' Then
GUICtrlCreateListViewItem($sItemName, $ListView1)
Assign('!' & $sItemName, $sItemName)
Else
MsgBox(0, '提示', '项目名称已经存在!')
EndIf
EndIf
EndSwitch
WEnd
Func _Random()
For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1
_GUICtrlListView_SetItemText($ListView1, $i, Random(1, 10000, 1), 1)
Next
EndFunc ;==>_Random
|