#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
$Debug_LV = False ; 检查传递给 ListView 函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
_Main()
Func _Main()
Local $hImage, $hListView
; 创建界面
GUICreate("列表中添加子项", 700, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 594, 268, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUISetState()
; 加载图像
$hImage = _GUIImageList_Create()
_GUIImageList_AddIcon($hImage, "radmin.exe", 1) ;0
_GUIImageList_AddIcon($hImage, "radmin.exe", 11);1
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
; 添加列
_GUICtrlListView_InsertColumn($hListView, 0, "ID", 0)
_GUICtrlListView_InsertColumn($hListView, 1, "名称", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "IP地址", 100)
_GUICtrlListView_InsertColumn($hListView, 3, "端口号", 100)
_GUICtrlListView_InsertColumn($hListView, 4, "用户名", 100)
_GUICtrlListView_InsertColumn($hListView, 5, "密码", 100)
_GUICtrlListView_InsertColumn($hListView, 6, "在线", 100)
; 添加项
For $x = 0 To 20
_GUICtrlListView_AddItem($hListView, $x, $x ,-1)
_GUICtrlListView_AddSubItem($hListView, $x , "1111", 1, 0)
_GUICtrlListView_AddSubItem($hListView, $x , "192.168.0.1", 2, -1)
_GUICtrlListView_AddSubItem($hListView, $x , "1111", 3, -1)
_GUICtrlListView_AddSubItem($hListView, $x , "00", 4, -1)
_GUICtrlListView_AddSubItem($hListView, $x , "0000", 5, -1)
_GUICtrlListView_AddSubItem($hListView, $x , "√", 6, -1)
Next
; 循环至用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main