回复 5# papapa314
问题还是摆在这儿吗?
就我所知道的应该只能通过循环来排序,也许应该还有另外的自动排序的函数吧,不过我没有找到。想了想,也许就算是有排序的函数应该也是通过循环来做的吧。
提供一个笨办法来解决楼主的困扰。方法很笨,慎用:
;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
;Opt('MustDeclareVars', 1)
;$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $iI, $hListView
; Create GUI
GUICreate("ListView Add Array", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
_GUICtrlListView_SetUnicodeFormat($hListView, False)
GUISetState()
; Add columns
_GUICtrlListView_AddColumn($hListView, "Items", 100)
_GUICtrlListView_AddColumn($hListView, "SubItems 1", 100)
_GUICtrlListView_AddColumn($hListView, "SubItems 2", 100)
_GUICtrlListView_AddColumn($hListView, "SubItems 3", 100)
_GUICtrlListView_SetItemCount($hListView, 5000)
; One column load
Local $aItems[10][2]
For $iI = 0 To UBound($aItems) - 1
$aItems[$iI][0] ="items"& $iI+1
Next
_GUICtrlListView_AddArray($hListView, $aItems)
;Local $Random=Random(0,9,1)
MsgBox(4096,'随机删除三行','随机删除三行')
_GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView),Random(0,_GUICtrlListView_GetitemCount($hListView),1))
_GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView),Random(0,_GUICtrlListView_GetitemCount($hListView),1))
_GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView),Random(0,_GUICtrlListView_GetitemCount($hListView),1))
msgbox(0,0,"重新排序")
local $count=_GUICtrlListView_GetitemCount($hListView)
for $i=0 to $count
if _GUICtrlListView_GetItemText($hListView,$i,0)<>$i+1 Then
_GUICtrlListView_SetItemText($hListView,$i,"Items"&$i+1)
EndIf
Next
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
|