首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

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

2012-12-17 
为什么我的Treeview总是有问题呢,请各位帮我看看Public Transtr As StringPublic index As IntegerFunctio

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

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


[最优解释]
看看这个例子你就不混乱了

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"

[其他解释]
总的说下啥问题吧

热点排行
Bad Request.