#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
Global $gui, $list1, $list2
GUICreate($gui, 400, 300)
list1()
list2()
$bt1 = GUICtrlCreateButton('切换1', 20, 270, 60, 20)
$bt2 = GUICtrlCreateButton('切换2', 100, 270, 60, 20)
GUICtrlSetState($list1, 16) ;可以先显示一个,注释此行则都不显示
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $bt1
GUICtrlSetState($list2, 32)
GUICtrlSetState($list1, 16)
Case $bt2
GUICtrlSetState($list1, 32)
GUICtrlSetState($list2, 16)
Case $list1
_GUICtrlListView_SortItems($list1, GUICtrlGetState($list1))
;~ MsgBox(262144, 'List1', 1)
Case $list2
_GUICtrlListView_SortItems($list2, GUICtrlGetState($list2))
;~ MsgBox(262144, 'List2', 2)
EndSwitch
WEnd
_GUICtrlListView_UnRegisterSortCallBack($list1)
_GUICtrlListView_UnRegisterSortCallBack($list2)
Func list1()
$list1 = GUICtrlCreateListView("英文 1|英文 2|英文 3", 10, 10, 280, 180)
_GUICtrlListView_AddItem($list1, 'aa')
_GUICtrlListView_AddSubItem($list1, 0, 'bb', 1)
_GUICtrlListView_AddSubItem($list1, 0, 'cc', 2)
_GUICtrlListView_AddItem($list1, 'dd')
_GUICtrlListView_AddSubItem($list1, 1, 'ee', 1)
_GUICtrlListView_AddSubItem($list1, 1, 'ff', 2)
_GUICtrlListView_RegisterSortCallBack($list1, 0)
GUICtrlSetState(-1, 32)
EndFunc ;==>list1
Func list2()
$list2 = GUICtrlCreateListView("数字 1|数字 2|数字 3|数字 4", 10, 10, 280, 180)
_GUICtrlListView_AddItem($list2, '11')
_GUICtrlListView_AddSubItem($list2, 0, '22', 1)
_GUICtrlListView_AddSubItem($list2, 0, '233', 2)
_GUICtrlListView_AddSubItem($list2, 0, '144', 3)
_GUICtrlListView_AddItem($list2, '55')
_GUICtrlListView_AddSubItem($list2, 1, '66', 1)
_GUICtrlListView_AddSubItem($list2, 1, '77', 2)
_GUICtrlListView_AddSubItem($list2, 1, '88', 3)
_GUICtrlListView_RegisterSortCallBack($list2, 1)
GUICtrlSetState(-1, 32)
EndFunc ;==>list2