ListView需要读取海量数据,请问有什么比较好的解决办法
本帖最后由 heavenm 于 2012-9-1 07:34 编辑#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#Region ### START Koda GUI section ### Form=D:\Form1.kxf
$Form1 = GUICreate("Form1", 623, 475, 195, 148)
$Group1 = GUICtrlCreateGroup("", 8, 80, 609, 385)
$ListView1 = GUICtrlCreateListView("内容", 16, 96, 594, 358)
_GUICtrlListView_SetColumnWidth($ListView1, 0, $LVSCW_AUTOSIZE_USEHEADER)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 8, 0, 609, 65)
$Label1 = GUICtrlCreateLabel("过滤", 24, 28, 28, 17)
$Input1 = GUICtrlCreateInput("6", 56, 24, 41, 21)
;$Checkbox1 = GUICtrlCreateCheckbox("空值", 104, 26, 49, 17)
$Button1 = GUICtrlCreateButton("开始", 328, 24, 83, 25)
$Button2 = GUICtrlCreateButton("停止", 520, 24, 83, 25)
$Button3 = GUICtrlCreateButton("导出", 424, 24, 83, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$OPEN_FLIE_PATH = FileOpenDialog('打开文件', @ScriptDir & "\", "所有文件 (*.*)", 1)
$STRING = FileRead($OPEN_FLIE_PATH)
$STRING_LENGTH = GUICtrlRead($Input1)
;MsgBox(0, '', ".*----.{" & $STRING_LENGTH & ",}")
$MATCH_STRING = StringRegExp($STRING, ".*----\S{" & $STRING_LENGTH & ",}", 3)
#include <Array.au3>
;_ArrayDisplay($MATCH_STRING)
;_GUICtrlListView_AddColumn($ListView1, "数据项", 100)
;_GUICtrlListView_SetItemCount($ListView1, 5)
;_GUICtrlListView_AddArray($ListView1, $MATCH_STRING)
For $i=0 To UBound($MATCH_STRING)-1
_GUICtrlListView_AddItem($ListView1, $MATCH_STRING[$i])
Next
Case $Button3
$SAVE_FILE_PATH = FileSaveDialog("保存文件", @ScriptDir & "\", "所有文件 (*.*)", 2 + 16)
_FileWriteFromArray($SAVE_FILE_PATH & '.txt', $MATCH_STRING)
Exit
EndSwitch
WEnd 谁能有比较快的解决办法!! 有人曾經PO過文章
http://www.autoitx.com/forum.php?mod=viewthread&tid=34526&highlight=listview
去看看吧 回复 1# heavenm
你要怎樣的解決方法是 想解決 資料讀取的問題還是 想解決 LISTVIEW 顯示慢的問題 读取前使用GUISetState(@SW_LOCK)将界面锁住,读取完后再解锁GUISetState(@SW_UNLOCK),就能解决LISTVIEW刷新慢的问题。当然你还可以加上_GUICtrlListView_BeginUpdate()和_GUICtrlListView_EndUpdate()来做一次性添加。
页:
[1]