GUICtrlCreateListViewItem
创建 ListView 控件的项目.
GUICtrlCreateListViewItem ( "text", listviewID )
参数
返回值
成功:
|
返回控件标识符(控件ID).
|
失败:
|
返回 0.
|
备注
函数创建 ListView 控件中可供选择的项目. 项目可以由 GUICtrlSetData() 设置数据.
如其它控件一样, 项目可由 GUICtrlDelete() 删除.
ListView 项目可以拖放到具有 $GUI_DROPACCEPTED 状态的编辑或输入控件.
关于列的大小调整查看 GUICtrlCreateListView() 函数.
特定标志 $GUI_BKCOLOR_LV_ALTERNATE 可交替设置 Listview 控件与 ListViewItem 项目的背景.
奇数行将获得 GUICtrlSetBkColor() 为 Listview 控件设置的颜色.
偶数行将获得 GUICtrlSetBkColor() 为 ListviewItem 项目设置的颜色.
上述常量需要 #include <GUIConstantsEx.au3>
相关
GUICtrlCreateListView, GUICtrlDelete, GUICtrlRead, GUICtrlSetData, GUICtrlSetState, GUIDataSeparatorChar (Option), GUIGetMsg
函数示例
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
GUISetBkColor(0x00E0FFFF) ; will change background color
Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) ;,$LVS_SORTDESCENDING)
Local $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
GUICtrlCreateInput("", 20, 200, 150)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
GUISetState(@SW_SHOW)
GUICtrlSetData($idItem2, "ITEM1")
GUICtrlSetData($idItem3, "||COL33")
GUICtrlDelete($idItem1)
; Loop until the user exits.
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idButton
MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)
Case $idListview
MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)
EndSwitch
WEnd
EndFunc ;==>Example
----------------------------------------
|