Private Sub FileSystem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Loadview()
End Sub
Private Sub Loadview()
TreeView1.Nodes.Clear()
Dim dimstr As String
For Each dimstr In System.IO.Directory.GetLogicalDrives
With TreeView1.Nodes.Add(dimstr)
.Nodes.Add(dummy)
End With
Next
End Sub
Private Sub TreeView1_BeforeExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeExpand
e.Node.Nodes.Clear()
Dim nod As New TreeNode
Dim strpath As String = e.Node.FullPath
Dim strdir As String
Dim strfile As String
With e.Node
For Each strdir In Directory.GetDirectories(strpath)
' Path.GetFileName returns just the file name portion
' of the full path returned from the GetDirectories
' method.
With e.Node.Nodes.Add(Path.GetFileName(strdir))
.Tag = 1
.Nodes.Add(dummy)
End With
Next
End With
With e.Node
For Each strfile In Directory.GetFiles(strpath)
With e.Node.Nodes.Add(Path.GetFileName(strfile))
.Tag = 2
End With
Next
End With
End Sub
TreeView1.Nodes.Add("Node1") '添加根节点
TreeView1.Nodes.Item(0).Nodes.Add("Node2") '添加子节点
'触发AFTERSELECT 事件
Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim SelectTree As TreeNode
SelectTree = e.Node() '返回选择的节点
If SelectTree.Text = "ASD" Then '获得节点的文本
sql_scn()
Else
ListView1.Items.Clear()
ListView1.Columns.Clear()
End If