标题:两个DataGride,怎么做关联?
取消只看楼主
chensenduxiang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-6-13
 问题点数:0 回复次数:0 
两个DataGride,怎么做关联?

我想通过两个DataGrid显示订单信息(DataGrid1)和订单分录信息(DataGrid2),。按照我下面的代码可以完成界面的加载,但是当我想单击DataGrid1里面的第二条订单的时候,Datagrid2里面就不能显示订单分录信息了。我不知道怎样能捕捉到Datagrid1的当前记录的字段值。或者能否直接关联?请大侠指点!

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim Dtl_SO As DataSet = New DataSet5
Dim adoRS As ADODB.Recordset = New ADODB.Recordset
Dim adors_SE As ADODB.Recordset = New ADODB.Recordset

Dim Fid As Integer

adoRS.Open("select * from Seord1 where [cusname]='" & Me.TreeView1.SelectedNode.Text & "'", Cnn1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly)
Fid = adoRS.Fields(0).Value
adors_SE.Open("select * from Seordentry1 where [finterid]=" & Fid, Cnn1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly)

Me.OleDbDataAdapter1.Fill(Me.DataSet51.Seord1, adoRS)
Me.OleDbDataAdapter2.Fill(Me.DataSet51.SeordEntry1, adors_SE)

DataGrid1.DataSource = Dtl_SO
DataGrid1.SetDataBinding(Me.DataSet51, "Seord1")

DataGrid2.DataSource = Dtl_SO
DataGrid2.SetDataBinding(Me.DataSet51, "Seord1.SeordEntry_R")
End Sub

搜索更多相关主题的帖子: DataGride 
2006-06-13 14:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-71951-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048308 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved