我做了一个窗体,如下图,我想点击列表中的某一行时,某一行的信息则自动返回到窗体的控件中去,但是不知道为什么,我无论点击列表中的哪一行,它只会返回第一行的信息...如下图所示....下面附上我的代码,请各位看看我的代码是不是出什么问题了...帮我改改...
Private Sub Form_Load()
rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3) '运用API函数SetWindowPos,来实现使窗体置前的功能
Dim strSql As String
Dim rs As Recordset
strSql = "select * from tb_gys"
Set rs = GetRecordSet(strSql)
Set DataGrid1.DataSource = rs
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Text1(0).Enabled = False
Text1(1).Enabled = False
Text1(2).Enabled = False
Text1(3).Enabled = False
Text1(4).Enabled = False
Text1(5).Enabled = False
End Sub
'*** 自定义数据信息反绑定的过程 ***
Private Sub JionBack()
On Error Resume Next '执行错误处理
Dim SLen As Integer
Dim strSql As String
Dim rs As Recordset
strSql = "select * from tb_gys"
Set rs = GetRecordSet(strSql)
If rs.RecordCount > 0 Then
StrNum = Val(rs.Fields("gys_ID"))
SLen = Len(Trim(StrNum))
Select Case SLen '位数不足者补0
Case 1
StrTemp = "00000"
Case 2
StrTemp = "0000"
Case 3
StrTemp = "000"
Case 4
StrTemp = "00"
Case 5
StrTemp = "0"
Case 6
StrTemp = ""
End Select
'将数据信息反绑定到文本框当中
Text1(0).Text = rs(1)
Text1(1).Text = rs(2)
Text1(2).Text = rs(3)
Text1(3).Text = rs(4)
Text1(4).Text = rs(5)
Text1(5).Text = rs(6)
End If
rs.Close
Set rs = Nothing
End Sub
[此贴子已经被作者于2007-8-28 11:35:11编辑过]