窗口afterShow事件
Dim labelPath As WinForm.Label = e.Form.Controls("Label4")
labelPath.text = ""
Dim ftp As new FTPClient
Dim dls As List(of String)
ftp.Host="192.168.66.218"
ftp.Account = "ftpUser"
ftp.Password = "123"
dls = ftp.GetDirList("")
Dim tree1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
For Each dl As String In dls
nd = tree1.Nodes.Add(dl,dl,"folder.ico")
nd.Nodes.Add(dl,dl,"folder.icon") ' 额外增加一个子节点,显示父节点有了+号
Next
dls = ftp.GetFileList("")
For Each dl As String In dls
tree1.Nodes.Add(dl,dl,"file.ico")
Next
在treeView控件的BeforeExpandNode时间中
Dim nd As WinForm.TreeNode
nd = e.Node
nd.Nodes.Clear
Dim strPath As String
strPath = nd.FullName
output.show(strPath)
Dim ftp As new FTPClient
Dim dls As List(of String)
ftp.Host="192.168.66.218"
ftp.Account = "ftpUser"
ftp.Password = "123"
dls = ftp.GetDirList(strPath)
Dim tree1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd1 As WinForm.TreeNode
For Each dl As String In dls
nd1 = nd.Nodes.Add(dl,dl,"folder.ico")
nd1.Nodes.Add(dl,dl,"folder.icon")
Next
dls = ftp.GetFileList(strPath)
For Each dl As String In dls
nd.Nodes.Add(dl,dl,"file.ico")
Next
点击展开时,删除子节点,重新加载文件/文件夹, 遇到文件夹的继续额外增加子节点