vb中treeview控件如何遍历某个选中节点下的所有子节点(不包括子节点的子节点)?
1个回答
展开全部
Private Sub Command1_Click()
Dim i As Integer
Dim nd As Node
List1.Clear
Set nd = TreeView1.SelectedItem.Child
For i = 1 To TreeView1.SelectedItem.Children
List1.AddItem nd.Text
Set nd = nd.Next
Next
End Sub
Private Sub Form_Load()
Dim i As Integer, j As Integer
TreeView1.LineStyle = tvwRootLines
TreeView1.LabelEdit = tvwManual
TreeView1.Nodes.Add , , "R", "R"
For i = 1 To 5
TreeView1.Nodes.Add "R", tvwChild, "A" & i, "A" & i
For j = 1 To 5
TreeView1.Nodes.Add "A" & i, tvwChild, "A" & i & "B" & j, "A" & i & "B" & j
Next
Next
End Sub
Dim i As Integer
Dim nd As Node
List1.Clear
Set nd = TreeView1.SelectedItem.Child
For i = 1 To TreeView1.SelectedItem.Children
List1.AddItem nd.Text
Set nd = nd.Next
Next
End Sub
Private Sub Form_Load()
Dim i As Integer, j As Integer
TreeView1.LineStyle = tvwRootLines
TreeView1.LabelEdit = tvwManual
TreeView1.Nodes.Add , , "R", "R"
For i = 1 To 5
TreeView1.Nodes.Add "R", tvwChild, "A" & i, "A" & i
For j = 1 To 5
TreeView1.Nodes.Add "A" & i, tvwChild, "A" & i & "B" & j, "A" & i & "B" & j
Next
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询