找回密码
 加入
搜索
查看: 3090|回复: 3

[AU3基础] 【已解决】如何把数据插入到GuiListView并保持在第一行?即插入的数据总在第一行

[复制链接]
发表于 2012-1-31 20:28:10 | 显示全部楼层 |阅读模式
本帖最后由 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
发表于 2012-1-31 21:41:22 | 显示全部楼层
26行
_GUICtrlListView_SetItemText($hListView, 0, '第二列', 1)

评分

参与人数 1金钱 +10 贡献 +5 收起 理由
auto + 10 + 5

查看全部评分

 楼主| 发表于 2012-1-31 21:51:09 | 显示全部楼层
本帖最后由 auto 于 2012-1-31 21:54 编辑

回复 2# afan


    帮助没仔细,老想用"abc|123"这样的操作方法,原来帮助已经说明了,不支持多个,

应该是。插入一空的,然后用循环来填充数据。。
发表于 2014-4-5 11:25:14 | 显示全部楼层
按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
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 11:14 , Processed in 0.082799 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表