Event: Treeview-AfterSelect
-
Greetings! I'm having trouble with my treeview. Once I select a node from the treeview, it invokes the AfterSelect event, re-fills my nodes and the re-executes the AfterSelect event (again) - thus re-filling my node tree:
Private Sub uxGpDirectoryTree_AfterSelect( _ ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) _ Handles uxGpDirectoryTree.AfterSelect Me.StartDir += uxGpDirectoryTree.SelectedNode.Text + "\" call fillDirectoryTree() End Sub Private Sub fillDirectoryTree() Dim arrSubfolders() As DirectoryInfo arrSubfolders = New DirectoryInfo(Me.StartDir).GetDirectories uxGpDirectoryTree.Nodes.Clear() For Each subfolder As DirectoryInfo In arrSubfolders uxGpDirectoryTree.Nodes.Add(subfolder.Name) Next End Sub
I have debugged and it does cycle more than once. Any help would be greatly appreciated. Thanks, Karen Nooobie to OOP and VB.Net 2005 -
Greetings! I'm having trouble with my treeview. Once I select a node from the treeview, it invokes the AfterSelect event, re-fills my nodes and the re-executes the AfterSelect event (again) - thus re-filling my node tree:
Private Sub uxGpDirectoryTree_AfterSelect( _ ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) _ Handles uxGpDirectoryTree.AfterSelect Me.StartDir += uxGpDirectoryTree.SelectedNode.Text + "\" call fillDirectoryTree() End Sub Private Sub fillDirectoryTree() Dim arrSubfolders() As DirectoryInfo arrSubfolders = New DirectoryInfo(Me.StartDir).GetDirectories uxGpDirectoryTree.Nodes.Clear() For Each subfolder As DirectoryInfo In arrSubfolders uxGpDirectoryTree.Nodes.Add(subfolder.Name) Next End Sub
I have debugged and it does cycle more than once. Any help would be greatly appreciated. Thanks, Karen Nooobie to OOP and VB.Net 2005 -
Greetings! I'm having trouble with my treeview. Once I select a node from the treeview, it invokes the AfterSelect event, re-fills my nodes and the re-executes the AfterSelect event (again) - thus re-filling my node tree:
Private Sub uxGpDirectoryTree_AfterSelect( _ ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) _ Handles uxGpDirectoryTree.AfterSelect Me.StartDir += uxGpDirectoryTree.SelectedNode.Text + "\" call fillDirectoryTree() End Sub Private Sub fillDirectoryTree() Dim arrSubfolders() As DirectoryInfo arrSubfolders = New DirectoryInfo(Me.StartDir).GetDirectories uxGpDirectoryTree.Nodes.Clear() For Each subfolder As DirectoryInfo In arrSubfolders uxGpDirectoryTree.Nodes.Add(subfolder.Name) Next End Sub
I have debugged and it does cycle more than once. Any help would be greatly appreciated. Thanks, Karen Nooobie to OOP and VB.Net 2005It looks like you're wiping out your entire TreeView, then refilling it with the subdirectories under the node that was selected. Is this really what you want? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome