#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 453, 190, 120)
$ListView1 = GUICtrlCreateListView("|||||||||||||||", 8, 200, 618, 246)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$Input1 = GUICtrlCreateInput("", 100, 16, 121, 21)
$Input2 = GUICtrlCreateInput("", 100, 56, 121, 21)
$Input3 = GUICtrlCreateInput("", 100, 96, 121, 21)
$Input4 = GUICtrlCreateInput("", 100, 136, 121, 21)
$Label1 = GUICtrlCreateLabel("id_usernum", 16, 16, 80, 17)
$Label2 = GUICtrlCreateLabel("id_key", 16, 56, 80, 17)
$Label3 = GUICtrlCreateLabel("id_name", 16, 96, 80, 17)
$Label4 = GUICtrlCreateLabel("id_idcard", 16, 136, 80, 17)
$Button1 = GUICtrlCreateButton("read", 400, 80, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
list()
EndSwitch
WEnd
Func list()
Local $listvalue, $id_usernum
$id_usernum = GUICtrlRead($Input1)
$Conn = ObjCreate("ADODB.Connection")
$Conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=RZXCard.mdb;Jet OLEDB:Database Password='rzx1218'")
$RS = ObjCreate("ADODB.Recordset")
$sentence = "select * from registerhistory where id_usernum='" & $id_usernum & "'"
$RS.ActiveConnection = $Conn
$RS.Open($sentence)
If $RS.eof Then
MsgBox(0, 0, "没有找到记录")
Else
GUICtrlSetData($Input2, $RS.Fields(3).value)
GUICtrlSetData($Input3, $RS.Fields(2).value)
GUICtrlSetData($Input4, $RS.Fields(6).value)
_GUICtrlListView_DeleteAllItems($ListView1)
For $i = 0 To ($RS.Fields.Count - 1)
_GUICtrlListView_SetColumn($ListView1, $i, $RS.Fields($i).Name)
Next
While (Not $RS.eof And Not $RS.bof)
For $i = 0 To ($RS.Fields.Count - 1)
$listvalue = $listvalue & $RS.Fields($i).value & "|" ;取得一行记录
Next
GUICtrlCreateListViewItem($listvalue, $ListView1);显示$listvalue
$RS.movenext ;移到下一条记录
$listvalue = "" ;清空
WEnd
$RS.close
$Conn.Close
EndIf
EndFunc ;==>list
这个代码中我想把$Button1设成可以按回车键来确定的要怎么设啊??
有人可以帮忙解决一下吗?
[ 本帖最后由 s77m72 于 2008-10-26 21:15 编辑 ] |