#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <WinAPISys.au3>
#include <GuiEdit.au3>
#include <array.au3>
Local $tText = DllStructCreate("wchar Text[512]") ;建个结构,用来放listview列数据
Local $GUI, $iITEM_COUNT = 10000
Local $sSomeString = ""
Local $aShowdata[0][3]
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$hGUI = GUICreate("ListView虚表 加载[" & $iITEM_COUNT & "]数据 复选框 原地编辑例子 By_Crossdoor", 500, 350,-1,-1)
$Button3 = GUICtrlCreateButton("修改", 180, 310, 75, 25)
$CHILDGUI2 = GUICreate("22", 500, 350, 0, 0, $WS_CHILD, -1, $hGUI)
$hListView = GUICtrlCreateListView("Item1|nSubItem1|nSubItem2", 2, 2, 494, 294, $LVS_SHOWSELALWAYS + $LVS_OWNERDATA, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT + $LVS_EX_DOUBLEBUFFER)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 180)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
GUICtrlSendMsg($hListView, $LVM_SETITEMCOUNT, $iITEM_COUNT, 0) ;设定数据总数
GUISetState(@SW_SHOW, $CHILDGUI2)
GUISetState(@SW_SHOW, $hGUI)
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case -3
ExitLoop
Case $Button3
ReDim $aShowdata[$iITEM_COUNT][3]
$sSomeString = Random(1, 255, 1)
For $i = 0 To $iITEM_COUNT - 1
$aShowdata[$i][0] = "爷爷" & $i & "-" & $sSomeString
$aShowdata[$i][1] = "爸爸" & $i & "-" & $sSomeString
$aShowdata[$i][2] = "儿子" & $i & "-" & $sSomeString
Next
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $s
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Local $iIndex = DllStructGetData($tNMHDR, 'Index')
Switch $iIDFrom
Case $hListView
Switch $iCode
Case -150, -177 ;$LVN_GETDISPINFOA = -150, $LVN_GETDISPINFOW = -177 请求显示数据
If Not IsArray($aShowdata) Then ContinueCase
If UBound($aShowdata) = 0 Then ContinueCase
$tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
$iIndex = Int(DllStructGetData($tInfo, "Item"))
$iSub = Int(DllStructGetData($tInfo, "SubItem"))
DllStructSetData($tText, "Text", $aShowdata[$iIndex][$iSub]) ;列数据放入$tText结构
DllStructSetData($tInfo, "Text", DllStructGetPtr($tText)) ;用$tText结构的指针来设置列数据
DllStructSetData($tInfo, "TextMax", StringLen($aShowdata[$iIndex][$iSub])) ;设置列数据长度
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY