#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
$Debug_LV = False ; 检查传递给函数的类名, 设置为真并使用另一控件句柄观察其工作
Global $hListView, $edit, $sa, $txit, $a, $Check
Local $GUI, $hImage
$GUI = GUICreate("(UDF Created) ListView Create", 500, 380)
$hListView = GUICtrlCreateListView('文件', 2, 2, 200, 330, $WS_BORDER)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))
_GUICtrlListView_SetView($hListView, 3);设置样式,可选(1、2、3、4)
$edit = GUICtrlCreateEdit("", 250, 2, 240, 330)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
GUISetState()
;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; 添加列
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 180)
; 添加项
For $i = 0 To 10
_GUICtrlListView_AddItem($hListView, "项目-" & $i, $i)
Next
; 循环至用户退出
While 1
$a = _GUICtrlListView_GetItemCount($hListView)
For $i = 0 To $a
$Check = _GUICtrlListView_GetItemChecked($hListView, $i)
If $Check = True Then
$txit &= _GUICtrlListView_GetItemText($hListView, $i) & @CRLF
EndIf
Next
If $txit <> $sa Then
GUICtrlSetData($edit, '')
GUICtrlSetData($edit, $txit, 1)
$sa = $txit
EndIf
$txit = ''
Switch GUIGetMsg()
Case -3
Exit
EndSwitch
WEnd
|