0
자식 노드의 항목은 접힌 상태에서 확장 될 때마다 스스로 복제되는 것처럼 보입니다. 문제는 확장하기 전에 메모리를 지워야한다는 것입니다. 누구든지이 사건이 일어날 이유를 알 수 있습니까? 미리 감사드립니다.Treenode 붕괴에서 확장되었을 때 중복 됨
Public Sub FillTree(ByVal s As String)
Dim nodeText As String = ""
Dim sb As New C_StringBuilder
With My.Computer.FileSystem
For i As Integer = 0 To .Drives.Count - 1
'** Build the drive's node text
sb.ClearText()
sb.AppendText(.Drives(i).Name.ToString)
nodeText = sb.FullText
'Check to see if DropDown Selection is the same as what has been read into i
If (sb.FullText = s) Then
'** Add the drive to the treeview
Dim driveNode As TreeNode
tvFolders.Nodes.Clear()
driveNode = tvFolders.Nodes.Add(nodeText)
driveNode.Tag = .Drives(i).Name
'** Add the next level of subfolders
ListLocalSubFolders(driveNode, .Drives(i).Name)
End If
Next
End With
End Sub
Private Sub ListLocalSubFolders(ByVal ParentNode As TreeNode, ByVal sParentPath As String)
' ' Add all local subfolders below the passed Local treeview node
Dim s As String
Try
For Each s In Directory.GetDirectories(sParentPath)
Dim childNode As TreeNode
childNode = ParentNode.Nodes.Add(FilenameFromPath(s))
childNode = Nothing
Next
Catch ex As Exception
End Try
End Sub
Private Sub tvFolders_BeforeExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles tvFolders.BeforeExpand
' Populate all child nodes below the selected node
Dim parentPath As String = e.Node.Tag
Dim childNode As TreeNode = e.Node.FirstNode
Do While childNode IsNot Nothing
ListLocalSubFolders(childNode, parentPath & childNode.Text)
childNode = childNode.NextNode
Loop
End Sub
감사합니다.하지만 실제로는 부모 노드를 자식 노드와 결합하여 확장 가능하게 만듭니다. – jpavlov