此方法能选中定位,看左边头,不能实现选中状态
在form_load事件里
Adodc5.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\vb1\KScount.mdb;Persist Security Info=False"‘根目录下vb1目录下有一个kscoun.mdb数据库
Adodc5.RecordSource = "select * from Tzy" Tzy是kscount的一个表
Adodc5.Refresh
Set DataGrid1.DataSource = Adodc5
DataGrid1.Refresh
Private Sub Command9_Click()’按钮事件里
Dim i As Integer
i = 0
If Adodc5.Recordset.RecordCount > 0 Then
Adodc5.Recordset.MoveFirst
Do While Not Adodc5.Recordset.EOF
i = i + 1
If Adodc5.Recordset.Fields("姓名") = Trim(Text6.Text) Then Exit Do
Adodc5.Recordset.MoveNext
Loop
End If
If Adodc5.Recordset.RecordCount = i Then
MsgBox ("没找到")
Else
DataGrid1.Row = i - 1
Text1.Text = Adodc5.Recordset.Fields("工号")
Text2.text=Adodc5.Recordset.Fields("姓名")
。。。。。。
End If
End Sub