| Description:The purpose of this code is to allow a user to search a treeview for a node. I have tried another one but it didn't work for me. Assumes:Make sure the treeview hideSelection is not checked in the treeview property pages Dim srchNode As Node Dim srchNodeIndex As Integer Private Sub FindNode(tV As TreeView, findString As String) 'This Subprocedure is used to find the nodes in the treeview If btnSearch.Caption = "Search" Then For Each srchNode In tV.Nodes If srchNode.Text = findString Then tV.SelectedItem = srchNode srchNode.EnsureVisible btnSearch.Caption = "Next" srchNodeIndex = srchNode.Index Exit Sub End If Next srchNode ElseIf btnSearch.Caption = "Next" Then For Each srchNode In tV.Nodes If srchNode.Index > srchNodeIndex Then If srchNode.Text = findString Then tV.SelectedItem = srchNode srchNode.EnsureVisible btnSearch.Caption = "Next" Exit Sub End If End If Next srchNode End If MsgBox findString & " was not found.", vbInformation, "Not Found" btnSearch.Caption = "Search" srchNodeInde End Sub |
TreeView Search Parent and Child |
Freelance ASP PHP web development | Web developer India Web development India| Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design