为什么我的Treeview总是有问题呢,请各位帮我看看

susgao 2012-08-29 01:21:15

Public Transtr As String
Public index As Integer



Function Treeview_Display()
Dim rs_tmp As New ADODB.Recordset
Dim tmpsql As String

index = 1
TreeView1.Nodes.Add , tvwLast, , "[客户一览表]"

tmpsql = "select distinct industry from tbl_company"
rs_tmp.Open tmpsql, conn, adOpenKeyset, adLockOptimistic

Do While Not rs_tmp.EOF
TreeView1.Nodes.Add 1, tvwChild, , "[行业/产业链] " & rs_tmp.Fields(0)
Transtr = rs_tmp.Fields(0)
Treeview2_Display
index = index + 1
rs_tmp.MoveNext
Loop

rs_tmp.Close
End Function

Function Treeview2_Display()

Dim rs_tmp2 As New ADODB.Recordset
Dim tmpsql2 As String

tmpsql2 = "select com_name from tbl_company where industry='" & Trim(Transtr) & "'"
rs_tmp2.Open tmpsql2, conn, adOpenKeyset, adLockOptimistic

Do While Not rs_tmp2.EOF
TreeView1.Nodes.Add index, tvwChild, , rs_tmp2.Fields(0)

rs_tmp2.MoveNext
Loop

rs_tmp2.Close
End Function

...全文
65 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
现在还是人类 2012-09-02
  • 打赏
  • 举报
回复
看看这个例子你就不混乱了

TreeView1.Nodes.Add , tvwLast, "根目录", "根目录"
TreeView1.Nodes.Add "根目录", tvwChild, "根目录_子目录1", "子目录1"
TreeView1.Nodes.Add "根目录", tvwChild, "根目录_子目录2", "子目录2"
TreeView1.Nodes.Add "根目录_子目录1", tvwChild, "根目录_子目录1_文件1", "文件1"
TreeView1.Nodes.Add "根目录_子目录1", tvwChild, "根目录_子目录1_文件2", "文件2"
TreeView1.Nodes.Add "根目录_子目录2", tvwChild, "根目录_子目录2_文件1", "文件1"
TreeView1.Nodes.Add "根目录_子目录2", tvwChild, "根目录_子目录2_文件2", "文件2"
twohorses 2012-09-01
  • 打赏
  • 举报
回复
总的说下啥问题吧

1,453

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧