我先做了个数据绑定,treeview结点显示的是数据表中的“cextpfabbname”字段的值
Private Sub filltree()
Dim mynode As Node
Dim rs As ADODB.Recordset
Set mynode = mytree.Nodes.add(, tvwFirst, "mother", "外加工工厂")
strcommand = "select cextpfabbname from dbo.Gy_ExtendProcess "
Set rs = cnn.Execute(strcommand)
Do While Not rs.EOF
Set mynode = mytree.Nodes.add("mother", tvwChild, , rs.Field("cextpfabbname").Value) rs.MoveNext
Loop
End Sub 我的问题是,当点击树中的一个节点时,可以在textbox中显示有关于这个节点的详细内容(即把表中的其他字段分别显示到每一个textbox中)
Private Sub filltree()
Dim mynode As Node
Dim rs As ADODB.Recordset
Set mynode = mytree.Nodes.add(, tvwFirst, "mother", "外加工工厂")
strcommand = "select cextpfabbname from dbo.Gy_ExtendProcess "
Set rs = cnn.Execute(strcommand)
Do While Not rs.EOF
Set mynode = mytree.Nodes.add("mother", tvwChild, , rs.Field("cextpfabbname").Value) rs.MoveNext
Loop
End Sub 我的问题是,当点击树中的一个节点时,可以在textbox中显示有关于这个节点的详细内容(即把表中的其他字段分别显示到每一个textbox中)
Private Sub Tree_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim RC_Node As Node
If Button = vbRightButton Then
Set RC_Node = tree.HitTest(X, Y)
If Not RC_Node Is Nothing Then Select Case RC_Node.Key
Case "SN"
...........................
end select跟你所要达到的稍有差别,但你看明白了,也就知道如何根据某个条件操作到一个具体的node
dim Rs as new recordset
dim strsql as string
strsql="Select * from dbo.Gy_ExtendProcess Where cextpfabbname='" & Node.text &"'"
set rs=cnn.excute(strsql)
'RS的输出就是这个节点的详细内容 End Sub