===================VB6 Treeview的添加节点子节点、Treeview打开、Treeview关闭'在窗体上方一个Treeview,四个command Option Explicit Private Sub Command1_Click() Static i As Integer TreeView1.Nodes.Add,"Text" & i,"Text" & i TreeView1.Nodes("Text" & i).Selected = True TreeView1.SetFocus i = i + 1 End Sub Private Sub Command2_Click() Static i As Integer TreeView1.Nodes.Add TreeView1.SelectedItem.Key,tvwChild,"TestSub" & i,"TestSub" & i TreeView1.SetFocus i = i + 1 End Sub Private Sub Command3_Click() Dim i As Integer For i = 1 To TreeView1.Nodes.Count If TreeView1.Nodes(i).Expanded = False Then TreeView1.Nodes(i).Expanded = True End If Next End Sub Private Sub Command4_Click() Dim i As Integer For i = 1 To TreeView1.Nodes.Count If TreeView1.Nodes(i).Expanded = True Then TreeView1.Nodes(i).Expanded = False End If Next End Sub Private Sub Form_Load() TreeView1.LineStyle = tvwRootLines TreeView1.Indentation = 200 Command1.Caption = "添加节点" Command2.Caption = "添加子节点" Command3.Caption = "展开所有" Command4.Caption = "收缩所有" End Sub
原文链接:https://www.f2er.com/vb/262333.html