database:beau ,user id :sa,password :123 ,local
treeRelation
(
person_depart_ID
person_depart_name
Highter_depart_name
Highter_depart_ID
level int
)
treeRelation
(
person_depart_ID
person_depart_name
Highter_depart_name
Highter_depart_ID
level int
)
{
treeview.Nodes.add(你的数据);
}大概就是这个意思
在下一次选中节点时,判断节点的boolOpen属性是否为真,如果为假,则表示节点下存在子节点,并且该节点下的子节点并为绑定,这时就可以作该节点的子节点的绑定操作,绑定完成后把boolOpen属性赋值为True。
Public Class UC_TreeNode
Inherits TreeNode Public Nodeid As String
Public boolOpen As Boolean Sub New(ByVal id As String, ByVal text As String, ByVal ImageIndex As Integer, Optional ByVal boolOpen As Boolean = True)
MyBase.New()
Nodeid = id '节点ID
Me.Text = text '节点名称
Me.ImageIndex = ImageIndex '节点图标
Me.SelectedImageIndex = ImageIndex '选中后的节点图标
Me.boolOpen = boolOpen '是否已经打开
End Sub
End Class
Private Sub bind()
Dim node As New UC_TreeNode(1, "MyFile", 0, False)
tre_File.Nodes.Add(node)
Dim iCount As Integer
iCount = 获得该节点下的是否存在子节点(数据库数据读取)
If iCount >= 1 Then
node.Nodes.Add("Nothing")
Else
node.boolOpen = True
End If
End Sub
我是用C#+sql的,現在可以實現了,真的很高興呀!
再次謝謝dazhu2