关于datagrid控件

来源:百度知道 编辑:UC知道 时间:2024/05/05 16:52:56
我用vb+access数据库。
我想在写一段代码可以获取datagrid控件当前指针指向的一行字段内容,datagrid控件名称是gdiscan,一行有二个字段:name,id.不知用什么语句可以实现查找出并显示在一个文本框中。请赐教.....
不是net

Private Sub Command3_Click()
Dim DataID As Integer

Set DBEmail = OpenDatabase(AppP & "data.mdb", ture, ture)
Set RSEMail = DBEmail.OpenRecordset("select name,type,note from info where ID=" & CInt(Trim(Text7.Text)), dbOpenDynaset, dbSeeChanges, dbOptimistic)
If RSEMail.EOF Then
MsgBox "没有这个ID的纪录!", vbInformation, "错误提示"
RSEMail.Close
Set RSEMail = Nothing
Text1.Text = ""
Text2.Text = ""
Exit Sub
End If
Text1.Text = RSEMail.Fields("name").Value & ""
Text2.Text = RSEMail.Fields("id").Value & ""
RSEMail.Close
Set RSEMail = Nothing

End Sub

是.net么
DataGridCell name = new DataGridCell(gdiscan.CurrentRowIndex, 0);
DataGridCell id = new DataGridCell(gdiscan.CurrentRowIndex, 1);

txtName.Text = name.ToString();
txtID.Text = id.ToString();