#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiTreeView.au3>
$Form1 = GUICreate("test", 500, 280)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 110)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 137)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 146)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 66)
$iImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($iImage, 'shell32.dll', 110)
_GUIImageList_AddIcon($iImage, 'shell32.dll', 137)
_GUIImageList_AddIcon($iImage, 'shell32.dll', 146)
_GUIImageList_AddIcon($iImage, 'shell32.dll', 66)
$TreeView = GUICtrlCreateTreeView(10, 10, 160, 260, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
_GUICtrlTreeView_SetNormalImageList($TreeView, $hImage)
$Group = _GUICtrlTreeView_Add($TreeView, 0, "分组列表", 0, 0)
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组01", 1, 2) ;生成分组列表
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组02", 1, 2) ;生成分组列表
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组03", 1, 2) ;生成分组列表
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组04", 1, 2) ;生成分组列表
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组05", 1, 2) ;生成分组列表
_GUICtrlTreeView_Expand($TreeView, $Group) ;展开列表
_GUICtrlTreeView_SelectItemByIndex($TreeView, $Group, 0) ;启动时默认选择第一个分组
$ListView = GUICtrlCreateListView("", 180, 10, 310, 260)
;;; !!! 与 TreeView 共用一个 ImageList
_GUICtrlListView_SetImageList($ListView, $hImage, 1)
;;; !!! 单独使用一个 ImageList
;~ _GUICtrlListView_SetImageList($ListView, $iImage, 1)
_GUICtrlListView_AddColumn($ListView, "1", 100) ;创建列
_GUICtrlListView_AddColumn($ListView, "2", 80) ;创建列
_GUICtrlListView_AddColumn($ListView, "3", 80) ;创建列
_GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) ;设置ListView样式
For $i = 1 To 5
_GUICtrlListView_AddItem($ListView, StringFormat("测试[%02d]", $i), 3)
_GUICtrlListView_AddSubItem($ListView, $i-1, "000", 1)
_GUICtrlListView_AddSubItem($ListView, $i-1, "000", 2)
Next
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd