Created
December 17, 2013 15:11
-
-
Save facebookegypt/8006419 to your computer and use it in GitHub Desktop.
VB 2010 Expand and Collapse two treeviews at the same time according to one another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Visual Basic Online Course [adonetaccess2003.blogspot.com] | |
'Expand and Collapse Treeviews | |
'Find a node in one treeview that matches another node | |
'in another treeview. | |
Private Sub TV1_AfterCollapse(sender As Object, _ | |
e As System.Windows.Forms.TreeViewEventArgs) _ | |
Handles TV1.AfterCollapse | |
TV1.SelectedNode = e.Node | |
Dim I As Integer = TV2.Nodes.Count - 1 | |
For sN As Integer = 0 To I | |
If TV2.Nodes(sN).Text = TV1.SelectedNode.Text Then | |
TV2.Nodes(sN).Collapse() | |
Exit For | |
Exit Sub | |
End If | |
Next | |
End Sub | |
Private Sub TV1_AfterExpand(sender As Object, _ | |
e As System.Windows.Forms.TreeViewEventArgs) _ | |
Handles TV1.AfterExpand | |
TV1.SelectedNode = e.Node | |
Dim I As Integer = TV2.Nodes.Count - 1 | |
For sN As Integer = 0 To I | |
If TV2.Nodes(sN).Text = TV1.SelectedNode.Text Then | |
TV2.Nodes(sN).Expand() | |
Exit For | |
Exit Sub | |
End If | |
Next | |
End Sub | |
Private Sub TV2_AfterCollapse(sender As Object, _ | |
e As System.Windows.Forms.TreeViewEventArgs) _ | |
Handles TV2.AfterCollapse | |
TV2.SelectedNode = e.Node | |
Dim I As Integer = TV1.Nodes.Count - 1 | |
For sN As Integer = 0 To I | |
If TV1.Nodes(sN).Text = TV2.SelectedNode.Text Then | |
TV1.Nodes(sN).Collapse() | |
Exit For | |
Exit Sub | |
End If | |
Next | |
End Sub | |
Private Sub TV2_AfterExpand(sender As Object, _ | |
e As System.Windows.Forms.TreeViewEventArgs) _ | |
Handles TV2.AfterExpand | |
TV2.SelectedNode = e.Node | |
Dim I As Integer = TV1.Nodes.Count - 1 | |
For sN As Integer = 0 To I | |
If TV1.Nodes(sN).Text = TV2.SelectedNode.Text Then | |
TV1.Nodes(sN).Expand() | |
Exit For | |
Exit Sub | |
End If | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment