标题:我的treeview代码错在哪?
只看楼主
DURED
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-5-8
 问题点数:0 回复次数:6 
我的treeview代码错在哪?
Dim rs1 As New ADODB.Recordset '定义数据集对象 Private nod As Node ------------------------------------------------------------------------- Private Sub Form_Load() Dim key, text As String Dim nod As Node Adodc1.RecordSource = "select * from p_xlkind order by spxlcode" Adodc1.Refresh If Adodc1.Recordset.RecordCount > 0 Then Adodc1.Recordset.MoveFirst Do While Adodc1.Recordset.EOF = False If Len(Trim(Adodc1.Recordset.Fields("spxlcode"))) = 2 Then key = Trim(Adodc1.Recordset.Fields("spxlcode")) text = "(" & Trim(Adodc1.Recordset.Fields("spxlcode")) & ")" & Trim(Adodc1.Recordset.Fields("sspxl")) Set node1 = TreeView1.Nodes.Add(, , key, text, 1) End If '运行这个地方报错,说无效关键字 If Len(Trim(Adodc1.Recordset.Fields("spxlcode"))) = 4 Then key = Trim(Adodc1.Recordset.Fields("spxlcode")) text = "(" & Trim(Adodc1.Recordset.Fields("spxlcode")) & ")" & Trim(Adodc1.Recordset.Fields("sspxl")) Set Node2 = TreeView1.Nodes.Add(node1.Index, tvwChild, key, text, 2) End If If Len(Trim(Adodc1.Recordset.Fields("spxlcode"))) = 6 Then key = Trim(Adodc1.Recordset.Fields("spxlcode")) text = "(" & Trim(Adodc1.Recordset.Fields("spxlcode")) & ")" & Trim(Adodc1.Recordset.Fields("sspxl")) Set Node3 = TreeView1.Nodes.Add(Node2.Index, tvwChild, key, text, 3) End If Adodc1.Recordset.MoveNext Loop End If End Sub

[此贴子已经被作者于2005-8-9 10:31:53编辑过]

搜索更多相关主题的帖子: treeview Node Dim 代码 
2005-08-09 10:24
DURED
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-5-8
得分:0 
没一个人?
2005-08-09 10:53
DURED
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-5-8
得分:0 
大侠,帮帮我呀
2005-08-09 12:22
ruhong
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-8-9
得分:0 
Set node1 = TreeView1.Nodes.Add(, , key, text, 1) 以及下面的 Set Node2 = TreeView1.Nodes.Add(node1.Index, tvwChild, key, text, 2) 这node1和node2哪来的啊,好象没有定义啊?
2005-08-09 12:56
ruhong
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-8-9
得分:0 
treeview 我用得不是很多,不是很熟, 我是这样的,直接用 TreeView1.Nodes.Add(, , key, text, 1) 你试试看
2005-08-09 12:57
DURED
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-5-8
得分:0 
Dim node1 As Node
Dim node2 As Node
Dim node3 As Node
定义了,还不行
2005-08-09 14:29
ruhong
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-8-9
得分:0 
你在 Set node1 = TreeView1.Nodes.Add(, , key, text, 1) 之前在debug.print key,text 看一下,看他们的值有没有问题 我找到以前我编的有关treeview的程序了,放上来你看看有没有帮助,我运行没啥问题. Private Sub load_treeview() Dim tree_rs As Recordset TreeView1.Style = 7 Set tree_rs = mydb.OpenRecordset("select distinct 语言 from 编程资料") 'mydb已经存在,不用理他. If Not tree_rs.RecordCount = 0 Then tree_rs.MoveLast tree_rs.MoveFirst For i = 1 To tree_rs.RecordCount If Not IsNull(tree_rs.Fields(0)) Then TreeView1.Nodes.Add , , "yy" & i, tree_rs.Fields(0), "tv1", "tv2" tree_rs.MoveNext End If Next End If For i = 1 To TreeView1.Nodes.Count Set tree_rs = mydb.OpenRecordset("select distinct 类别 from 编程资料 where 语言='" & TreeView1.Nodes(i).Text & "'") If Not tree_rs.RecordCount = 0 Then tree_rs.MoveLast tree_rs.MoveFirst For j = 1 To tree_rs.RecordCount If Not Len(tree_rs.Fields(0)) = 0 Then TreeView1.Nodes.Add "yy" & i, 4, "yy" & i & j, tree_rs.Fields(0), "tv1", "tv2" tree_rs.MoveNext Next End If Next End Sub
2005-08-09 17:24



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




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

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