【已解决】如何把数据插入到GuiListView并保持在第一行?即插入的数据总在第一行
本帖最后由 auto 于 2012-1-31 21:54 编辑#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
_Main()
Func _Main()
Local $hListView
GUICreate("ListView Insert Item", 450, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 420, 268)
GUISetState()
; Insert columns
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
_GUICtrlListView_SetColumnWidth($hListView, 0, 200);
_GUICtrlListView_SetColumnWidth($hListView, 1, 200);
; Add items
;_GUICtrlListView_SetColumn($hListView, 0, "111111111", 150, 1)
_GUICtrlListView_InsertItem($hListView, "Item 1", 0)
_GUICtrlListView_InsertItem($hListView, "Item 2", 1)
_GUICtrlListView_InsertItem($hListView, "如何插入数据到第一行的第二列呢?", 0)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main 26行_GUICtrlListView_SetItemText($hListView, 0, '第二列', 1) 本帖最后由 auto 于 2012-1-31 21:54 编辑
回复 2# afan
帮助没仔细,老想用"abc|123"这样的操作方法,原来帮助已经说明了,不支持多个,
应该是。插入一空的,然后用循环来填充数据。。 按auto说的写了个删除、插入的例子,免得阅读此帖的人一头雾水。
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Outfile=-32.exe
#PRE_Outfile_x64=-64.exe
#PRE_Compile_Both=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
GUICreate("test")
$del = GUICtrlCreateButton("删除选定行",20,10,90,23)
$add = GUICtrlCreateButton("插入新行",120,10,90,23)
$lsv = GUICtrlCreateListView("ID|Name|Age",20,70,300,200)
GUICtrlCreateListViewItem("1|aa1|21",$lsv)
GUICtrlCreateListViewItem("2|aa2|21",$lsv)
GUICtrlCreateListViewItem("3|aa3|21",$lsv)
GUISetState()
Func del()
MsgBox(0,0,GUICtrlRead(GUICtrlRead($lsv)))
_GUICtrlListView_DeleteItemsSelected($lsv)
_GUICtrlListView_EndUpdate($lsv)
EndFunc
Func add()
_GUICtrlListView_InsertItem($lsv,"11",0)
_GUICtrlListView_SetItemText($lsv,0,"TOM",1)
_GUICtrlListView_SetItemText($lsv,0,"99",2)
EndFunc
While 1
$msg = GUIGetMsg()
switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $del
del()
Case $add
add()
EndSwitch
WEnd
页:
[1]