回复 1# newuser
不大理解你表达的意思.
是将数组加入LISTVIEW的分组里?
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
Opt('MustDeclareVars', 1)
$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hImage, $hListView
;~ Local $hListView
GUICreate("ListView Insert Group", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
; Enable extended control styles
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
;_GUICtrlListView_SetUnicodeFormat($hListView, False)
GUISetState()
; 加载图象或颜色块
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
; _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16) 列表句柄,颜色,宽,高
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
_GUIImageList_AddBitmap($hImage, "D:\zgk_2010\autoit\CommonDataArea\close_1.bmp");也可以添加BMP图标
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
; 添加列
_GUICtrlListView_AddColumn($hListView, "Column 1", 100)
_GUICtrlListView_AddColumn($hListView, "Column 2", 100)
_GUICtrlListView_AddColumn($hListView, "Column 3", 100)
; 为列表视图控件分配100项目内存---新学到的
_GUICtrlListView_SetItemCount($hListView, 5003)
; 添加列表项
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1, 0)
;正如本例,如果ListView设置了3个列,那么最初只设置了0项第0列,想再后续添加后续列,那么就添加 子项,这或许就是二者的不同吧!
;最后的0是 images list的序列号,也是从0开始,上面为ImageList设置了3个项,即从 0 - 2
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2, 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1, 2)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
;以下是插入1个数组
; One column load
Local $aItems[30][3], $iI
For $iI = 0 To UBound($aItems) - 1
$aItems[$iI][0] = "Item " & $iI & "-0"
$aItems[$iI][1] = "Item " & $iI & "-1"
$aItems[$iI][2] = "Item " & $iI & "-2"
Next
_GUICtrlListView_AddArray(GUICtrlGetHandle($hListView), $aItems)
_GUICtrlListView_EnableGroupView($hListView);允许或禁止 列表项 作为组显示
_GUICtrlListView_InsertGroup($hListView, -1, 1, "Group 1-新建立的第1个Group的头标题")
_GUICtrlListView_InsertGroup($hListView, -1, 2, "Group 2", 1)
;-1表示组被添加到列表的尾部
;最后的1表示 组的头标题-Group2 居中显示
_GUICtrlListView_InsertGroup($hListView, -1, 3, "Group3", 2)
For $i=0 To 2
For $n=0 To 9
_GUICtrlListView_SetItemGroupID($hListView, $i*10+$n, $i+1);0是 列表项的索引 ,1 是组的索引
Next
Next
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
|