设置项目的部分或全部属性,使用数据结构.
#Include <GuiListView.au3>
_GUICtrlListView_SetItemEx($hWnd, ByRef $tItem)
$hWnd | 控件句柄 |
$tItem | $tagLVITEM 结构 |
成功: | 返回 True |
失败: | 返回 False |
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
$Debug_LV = False ; 检查传递给 ListView 函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
_Main()
Func _Main()
Local $tText, $tItem, $hListView
GUICreate("ListView Set Item Ex", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
GUISetState()
; 添加列
_GUICtrlListView_AddColumn($hListView, "Items", 100)
; 添加项目
GUICtrlCreateListViewItem("Item 1", $hListView)
GUICtrlCreateListViewItem("Item 2", $hListView)
GUICtrlCreateListViewItem("Item 3", $hListView)
; Change item 2
MsgBox(4160, "信息", "Changing item 2")
$tText = DllStructCreate("wchar Text[11]")
$tItem = DllStructCreate($tagLVITEM)
DllStructSetData($tText, "Text", "New Item 2")
DllStructSetData($tItem, "Mask", $LVIF_TEXT)
DllStructSetData($tItem, "Item", 1)
DllStructSetData($tItem, "Text", DllStructGetPtr($tText))
_GUICtrlListView_SetItemEx($hListView, $tItem)
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main