VB treeview的父节点怎么动态的在自己的名称后面显示它对应下面的子节点的个数???
1个回答
展开全部
给你个例子,看看吧。注意每个Node结尾都要是“(”。
代码如下。
====================
Private Sub Form_Load()
TreeView1.Nodes.Add , , "a1", "a1("
TreeView1.Nodes.Add "a1", tvwChild, "a11", "a11("
TreeView1.Nodes.Add "a1", tvwChild, "a12", "a12("
TreeView1.Nodes.Add , , "b", "b("
For i = 1 To 10
TreeView1.Nodes.Add "b", tvwChild, , "b" & i & "("
Next
End Sub
Private Sub TreeView1_Click()
Dim node As node
For Each node In TreeView1.Nodes
node.Text = Left(node.Text, InStr(1, node.Text, "(") - 1) & "(" & node.Children & ")"
Next
End Sub
代码如下。
====================
Private Sub Form_Load()
TreeView1.Nodes.Add , , "a1", "a1("
TreeView1.Nodes.Add "a1", tvwChild, "a11", "a11("
TreeView1.Nodes.Add "a1", tvwChild, "a12", "a12("
TreeView1.Nodes.Add , , "b", "b("
For i = 1 To 10
TreeView1.Nodes.Add "b", tvwChild, , "b" & i & "("
Next
End Sub
Private Sub TreeView1_Click()
Dim node As node
For Each node In TreeView1.Nodes
node.Text = Left(node.Text, InStr(1, node.Text, "(") - 1) & "(" & node.Children & ")"
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询