映射项目索引到 ID
#Include <GuiListView.au3>
_GUICtrlListView_MapIndexToID($hWnd, $iIndex)
$hWnd | 控件句柄 |
$iIndex | 项目的 0 基索引 |
返回项目的 ID |
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
$Debug_LV = False ; 检查传递给 ListView 函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
_Main()
Func _Main()
Local $iID, $hListView
GUICreate("ListView Map Index To ID", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
GUISetState()
; Add column
_GUICtrlListView_AddColumn($hListView, "Items", 100)
; 添加项目
_GUICtrlListView_AddItem($hListView, "Item 1")
_GUICtrlListView_AddItem($hListView, "Item 2")
_GUICtrlListView_AddItem($hListView, "Item 3")
; Show ID for item 2
$iID = _GUICtrlListView_MapIndexToID($hListView, 1)
MsgBox(4160, "信息", "Index to ID: " & $iID)
MsgBox(4160, "信息", "ID to Index: " & _GUICtrlListView_MapIDToIndex($hListView, $iID))
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main