关于添加数据到listview内。
新手求助,添加数据到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
本帖最后由 netegg 于 2012-11-19 22:38 编辑
单条添加?#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 没看懂要干什么 回复 2# netegg
蛋哥,密码那栏,输入数字的时候。整列都会跟着一起改变。。。
虽然使用GUICtrlCreateListViewItem ($account&"|"&$password,$ListView1)就可以达到要求,就想问下我到底错在哪了 $z,addsubitem时不是指定都要填的吗? 本帖最后由 netegg 于 2012-11-19 20:13 编辑
明白你的意思了,你那个没建项(第一列),子项当然建不出来
.........
For $z=0 To 999
_GUICtrlListView_AddItem($ListView1, $account)
_GUICtrlListView_AddSubItem($ListView1,$z,$password, 1 );控件,行,文本,列
next
EndSwitch
蛋哥,估计我没说清楚我要表达的。。。我的想法是添加记录,但是添加记录的时候,密码那列,显示的都是输入框的值。而无法保留上次输入的值。我就想点击一次,保存一条记录。。但事与愿违。 $z = _GUICtrlListView_AddItem($ListView1, $account)
;For $z = 0 To 999
_GUICtrlListView_AddSubItem($ListView1, $z, $password, 1);控件,行,文本,列
;Next 谢谢蛋哥跟A饭哥的帮助。。你们辛苦了{:face (317):}。。。这边蛋哥出力比较多,选择蛋哥,希望A饭哥不介意啦。嘻嘻! 再次谢谢A饭哥跟蛋哥!!
页:
[1]