找回密码
 加入
搜索
查看: 6446|回复: 9

[AU3基础] 关于添加数据到listview内。

  [复制链接]
发表于 2012-11-19 14:26:05 | 显示全部楼层 |阅读模式
悬赏10金钱已解决
新手求助,添加数据到listview里面,现在却有一个问题,密码那列添加却无法正常更新。。。。。。好久没上来了。。。问题很基础,但看帮助好含糊,我有点笨。求指教。

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 435, 224, 336, 150)
$ListView1 = GUICtrlCreateListView("", 0, 0, 433, 177)
_GUICtrlListView_AddColumn($ListView1, "账号", 200)
_GUICtrlListView_AddColumn($ListView1, "密码", 200)
$Input1 = GUICtrlCreateInput("", 40, 192, 121, 21)
$Label1 = GUICtrlCreateLabel("账号:", 0, 192, 40, 17)
$Label2 = GUICtrlCreateLabel("密码:", 176, 192, 40, 17)
$Input2 = GUICtrlCreateInput("", 216, 192, 121, 21)
$Button1 = GUICtrlCreateButton("添加", 352, 192, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $account = GUICtrlRead($Input1)
                        $password = GUICtrlRead($Input2)
                        ;_GUICtrlListView_DeleteAllItems($ListView1)
                        _GUICtrlListView_AddItem($ListView1, $account)
                For $z=0 To 999 
                        _GUICtrlListView_AddSubItem($ListView1,$z,$password, 1 );控件,行,文本,列
                next
        EndSwitch
WEnd
附件: 您需要 登录 才可以下载或查看,没有账号?加入

最佳答案

查看完整内容

单条添加?[au3]#include #include #include #include #include #include #include #include #include #include #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 435, 224, 336, 150) $ListView1 = GUICtrlCreateListView("", 0, 0, 433, 177) _GUICtrlListView_AddColumn($ListView1, "账号", 200) _GUICtrlListView_AddColumn($ListView1, "密码", 200) $Input1 = GUICtrlCreateInput("", ...
发表于 2012-11-19 14:26:06 | 显示全部楼层
本帖最后由 netegg 于 2012-11-19 22:38 编辑

单条添加?[au3]#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 435, 224, 336, 150)
$ListView1 = GUICtrlCreateListView("", 0, 0, 433, 177)
_GUICtrlListView_AddColumn($ListView1, "账号", 200)
_GUICtrlListView_AddColumn($ListView1, "密码", 200)
$Input1 = GUICtrlCreateInput("", 40, 192, 121, 21)
$Label1 = GUICtrlCreateLabel("账号:", 0, 192, 40, 17)
$Label2 = GUICtrlCreateLabel("密码:", 176, 192, 40, 17)
$Input2 = GUICtrlCreateInput("", 216, 192, 121, 21)
$Button1 = GUICtrlCreateButton("添加", 352, 192, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $account = GUICtrlRead($Input1)
                        $password = GUICtrlRead($Input2)
                        ;_GUICtrlListView_DeleteAllItems($ListView1)
                        _GUICtrlListView_AddItem($ListView1, $account)
                        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1, $password, 1)
                        GUICtrlSetData($Input1, '')
                        GUICtrlSetData($Input2, '')
        EndSwitch
WEnd[/au3]

评分

参与人数 1金钱 +30 收起 理由
xyhqqaa + 30 蛋哥。辛苦了。。。您老出力最大。万分感谢 ...

查看全部评分

发表于 2012-11-19 14:39:24 | 显示全部楼层
没看懂要干什么
 楼主| 发表于 2012-11-19 14:44:08 | 显示全部楼层
回复 2# netegg

蛋哥,密码那栏,输入数字的时候。整列都会跟着一起改变。。。
虽然使用GUICtrlCreateListViewItem ($account&"|"&$password,$ListView1)就可以达到要求,就想问下我到底错在哪了
发表于 2012-11-19 15:12:31 | 显示全部楼层
$z,addsubitem时不是指定都要填的吗?
发表于 2012-11-19 20:10:44 | 显示全部楼层
本帖最后由 netegg 于 2012-11-19 20:13 编辑

明白你的意思了,你那个没建项(第一列),子项当然建不出来
[au3] .........
                 For $z=0 To 999
                        _GUICtrlListView_AddItem($ListView1, $account)
                        _GUICtrlListView_AddSubItem($ListView1,$z,$password, 1 );控件,行,文本,列
                next
        EndSwitch
[/au3]

评分

参与人数 1金钱 +10 收起 理由
xyhqqaa + 10 囧。。谢谢蛋哥。。虽然还是错的

查看全部评分

 楼主| 发表于 2012-11-19 20:55:20 | 显示全部楼层
蛋哥,估计我没说清楚我要表达的。。。我的想法是添加记录,但是添加记录的时候,密码那列,显示的都是输入框的值。而无法保留上次输入的值。我就想点击一次,保存一条记录。。但事与愿违。
发表于 2012-11-19 21:26:34 | 显示全部楼层
                        $z = _GUICtrlListView_AddItem($ListView1, $account)
                        ;For $z = 0 To 999
                                _GUICtrlListView_AddSubItem($ListView1, $z, $password, 1);控件,行,文本,列
                        ;Next

评分

参与人数 1金钱 +60 收起 理由
xyhqqaa + 60 哇。。。。Afan哥都来了。。。答案好言简意 ...

查看全部评分

 楼主| 发表于 2012-11-20 08:27:52 | 显示全部楼层
谢谢蛋哥跟A饭哥的帮助。。你们辛苦了。。。这边蛋哥出力比较多,选择蛋哥,希望A饭哥不介意啦。嘻嘻!

评分

参与人数 1金钱 +20 收起 理由
afan + 20 很公正严明 ^ ^

查看全部评分

 楼主| 发表于 2012-11-20 08:29:05 | 显示全部楼层
再次谢谢A饭哥跟蛋哥!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-10 21:01 , Processed in 0.093447 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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