我有下面的代碼,但似乎無法找到一個原因(也不是解決方案),爲什麼父節點不斷出現在列表的末尾作爲重複?不需要的treeview節點複製在列表的末尾
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim di As New IO.DirectoryInfo("c:\la")
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
For Each dra In diar1
'Dim sr As StreamReader = New StreamReader(dra.FullName)
If System.IO.Path.GetExtension(dra.Name).ToLower() = ".xls" Then
TreeView1.Nodes.Add("Offerts")
TreeView1.Nodes(0).Nodes.Add(dra.Name)
End If
Next
End Sub
End Class
該代碼沒有任何意義,您需要描述您在樹完成後所期望的結果。 –