关于VB6.0中DATAGRID的问题
如图所示的界面,想实现的功能就是用户查询到记录后,在DATAGRID里面点一下,就能选择一行,并且在下面的标签里面就能显示关于此产品的介绍。产品的介绍也在ACCESS表中...
如图所示的界面,想实现的功能就是用户查询到记录后,在DATAGRID里面点一下,就能选择一行,并且在下面的标签里面就能显示关于此产品的介绍。产品的介绍也在ACCESS表中的一个字段里。
展开
2010-12-24
展开全部
Private Sub DataGrid1_Click()
'工程引用Microsoft activex data objects 2.8 library
Dim Cnn As New ADODB.Connection
Dim Rst As New ADODB.Recordset
Cnn.CursorLocation = adUseClient
Rst.CursorLocation = adUseClient
Rst.CursorType = adOpenKeyset
Rst.LockType = adLockOptimistic
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & DBpath & "\DBname.mdb;Persist " _
& "Security Info=False;Jet OLEDB:Database Password=;"
Set Rst = Cnn.Execute(查询语句)
Set DataGrid1.DataSource = Rst
End Sub
'然后在DataGrid1事件中给控件赋值
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
Text1.Text = DataGrid1.Columns(1).Text
'....
'....
'以下依次......
End Sub
'工程引用Microsoft activex data objects 2.8 library
Dim Cnn As New ADODB.Connection
Dim Rst As New ADODB.Recordset
Cnn.CursorLocation = adUseClient
Rst.CursorLocation = adUseClient
Rst.CursorType = adOpenKeyset
Rst.LockType = adLockOptimistic
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & DBpath & "\DBname.mdb;Persist " _
& "Security Info=False;Jet OLEDB:Database Password=;"
Set Rst = Cnn.Execute(查询语句)
Set DataGrid1.DataSource = Rst
End Sub
'然后在DataGrid1事件中给控件赋值
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
Text1.Text = DataGrid1.Columns(1).Text
'....
'....
'以下依次......
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询