回复 12# minghui
嗯,字符串排序的确是比较麻烦.
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <array.au3>
Opt("GUIOnEventMode", 1)
Global $n = 41
Local $Checkbox[$n][2], $wh = 30, $var = 265
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 621, 316, 192, 124)
GUISetOnEvent(-3, "_Exit")
$ListView1 = GUICtrlCreateListView("项目1|项目2|项目3", 4, 16, 245, 281, $LVS_SORTASCENDING)
GUICtrlSetOnEvent(-1, "Listview_Sort")
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 80)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 80)
$hListView = GUICtrlGetHandle($ListView1)
_GUICtrlListView_RegisterSortCallBack($hListView)
For $i = 1 To $n - 1
$varr = $wh * Int(($i - 1) / 4) + 16
$Checkbox[$i][1] = GUICtrlCreateCheckbox("复选框" & $i, $var, $varr, 81, 17)
GUICtrlSetOnEvent(-1, "_Check")
$var += 88
If $var = 617 Then $var = 265
Next
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(10)
WEnd
Func _Exit()
Exit
EndFunc ;==>_Exit
Func _Check()
Local $index_set, $index_get
Switch GUICtrlRead(@GUI_CtrlId)
Case 1
$index_set = _GUICtrlListView_AddItem($hListView, "复选框数据-" & StringFormat("%02d", @GUI_CtrlId - 3))
_GUICtrlListView_SetItemParam($hListView, $index_set, @GUI_CtrlHandle)
For $i = 1 To 2
_GUICtrlListView_AddSubItem($hListView, $index_set, "第" & @GUI_CtrlId - 3 & "项第" & $i & "列子数据", $i)
Next
Case 4
$index = _GUICtrlListView_FindParam($hListView, @GUI_CtrlHandle)
_GUICtrlListView_EnsureVisible($hListView, $index)
_GUICtrlListView_DeleteItem($hListView, $index)
EndSwitch
EndFunc ;==>_Check
Func Listview_Sort()
_GUICtrlListView_SortItems($hListView, GUICtrlGetState($ListView1))
EndFunc ;==>Listview_Sort
|