Y
you
Ok, I hope that I can 'splain this right. I am very new so bear with me.
I have a treeview with its main node being a user selected folder. In
this treeview you can only see subfolders and two specific file types.
What I am trying to do next is to remove any subfolders from the tree
that bo not have any of the two file types. This is done to somewhat
unclutter the tree.
Here is my code so far to clear the folders out. It is called with the
topmost node as the inputnode to start with.
Private Sub RemoveUselessFolders(inputnode as TreeNode)
Try
Dim node As TreeNode
For Each node In inputnode.Nodes
If node.ImageIndex < 2 Then 'it is a folder
If node.Nodes.Count = 0 Then 'it has no subfolders-can remove
node.Remove
Else
RemoveUselessFolders(node)
End If
End If
Next
Catch ex As system.NullReferenceException
End Try
End Sub
This seems to throw NullReferenceException's and maybe deletes a folder
and maybe not. I just do not understand why this does not work. I do not
have VS, so I can not step through it and see what is (or isn't)
happening. Anyone have a clue?
If you need more info please let me know.
Thanks,
Jason
I have a treeview with its main node being a user selected folder. In
this treeview you can only see subfolders and two specific file types.
What I am trying to do next is to remove any subfolders from the tree
that bo not have any of the two file types. This is done to somewhat
unclutter the tree.
Here is my code so far to clear the folders out. It is called with the
topmost node as the inputnode to start with.
Private Sub RemoveUselessFolders(inputnode as TreeNode)
Try
Dim node As TreeNode
For Each node In inputnode.Nodes
If node.ImageIndex < 2 Then 'it is a folder
If node.Nodes.Count = 0 Then 'it has no subfolders-can remove
node.Remove
Else
RemoveUselessFolders(node)
End If
End If
Next
Catch ex As system.NullReferenceException
End Try
End Sub
This seems to throw NullReferenceException's and maybe deletes a folder
and maybe not. I just do not understand why this does not work. I do not
have VS, so I can not step through it and see what is (or isn't)
happening. Anyone have a clue?
If you need more info please let me know.
Thanks,
Jason