标题:请教,treeview控件使用
取消只看楼主
liuxinzz
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-8-24
 问题点数:0 回复次数:0 
请教,treeview控件使用

我希望在access中使用treeview,但是可以连接两个表,第三个表连接总是出现循环问题,希望得到帮助。 代码如下: Private Sub Form_Load() TreeView0.LineStyle = tvwRootLines

Dim shengrs As ADODB.Recordset Dim shirs As ADODB.Recordset Dim xianjirs As ADODB.Recordset

Set shengrs = New ADODB.Recordset shengrs.CursorLocation = adUseClient shengrs.Open "select sheng,id from sheng ORDER BY id ", CurrentProject.Connection, 1 If shengrs.RecordCount > 0 Then shengrs.MoveFirst Do While shengrs.EOF = False Set mnode1 = TreeView0.Nodes.Add(, , shengrs.Fields("sheng"), shengrs.Fields("sheng")) Set shirs = New ADODB.Recordset shirs.CursorLocation = adUseClient shirs.Open "select shi,id ,shengid from shi ORDER BY id ", CurrentProject.Connection, 1 shirs.MoveFirst Do While shirs.EOF = False If shirs.Fields("shengid") = shengrs.Fields("id") Then Set mnode2 = TreeView0.Nodes.Add(mnode1.Key, tvwChild, shirs.Fields("shi"), shirs.Fields("shi")) End If Set xianrs = New ADODB.Recordset xianrs.CursorLocation = adUseClient xianrs.Open "select xian,id,shiid from xian ORDER BY id ", CurrentProject.Connection, 1 xianrs.MoveFirst Do While xianrs.EOF = False If xianrs.Fields("shiid") = shirs.Fields("id") Then Set mnode3 = TreeView0.Nodes.Add(mnode2.Key, tvwChild, , xianrs.Fields("xian")) End If xianrs.MoveNext Loop shirs.MoveNext Loop shengrs.MoveNext Loop End If

End Sub

搜索更多相关主题的帖子: treeview 控件 
2005-09-15 14:21



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




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

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