This commit is contained in:
Jonathan Jenne
2017-05-29 15:28:51 +02:00
parent 078ba6b8cd
commit 0f8f8ddf65
5 changed files with 235 additions and 6 deletions

View File

@@ -673,20 +673,20 @@ Public Class frmConstructor_Main
Return Nothing
End Function
Dim NodesThatMatch As New List(Of TreeNode)
Private Function SearchTheTreeView(ByVal TV As TreeView, ByVal TextToFind As String) As TreeNode
Private Function SearchTheTreeView(ByVal TV As TreeView, ByVal TextToFind As String) As List(Of TreeNode)
' Empty previous
NodesThatMatch.Clear()
' Keep calling RecursiveSearch
For Each TN As TreeNode In TV.Nodes
If TN.Text = TextToFind Then
If TN.Text.Contains(TextToFind) Then
NodesThatMatch.Add(TN)
End If
RecursiveSearch(TN, TextToFind)
Next
If NodesThatMatch.Count > 0 Then
Return NodesThatMatch(0)
Return NodesThatMatch
Else
Return Nothing
End If
@@ -6651,16 +6651,30 @@ Public Class frmConstructor_Main
End If
End Sub
Private Sub tstxtboxSearchNode_KeyUp(sender As Object, e As KeyEventArgs) Handles tstxtboxSearchNode.KeyUp
If e.KeyCode = Keys.Return Then
If SearchTheTreeView(TreeViewMain, tstxtboxSearchNode.Text) Is Nothing Then
Dim Result As List(Of TreeNode) = SearchTheTreeView(TreeViewMain, tstxtboxSearchNode.Text)
If Result Is Nothing Then
MessageBox.Show("No Match Found")
Else
TreeViewMain.SelectedNode = SearchTheTreeView(TreeViewMain, tstxtboxSearchNode.Text)
If Result.Count = 1 Then
TreeViewMain.SelectedNode = Result.First()
Else
Dim resultForm As New frmTreeSearchResult()
resultForm.searchResultNodes = Result
resultForm.constructorForm = Me
resultForm.Show()
End If
End If
End If
End Sub
Public Sub SetSelectedTreeViewNode(node As TreeNode)
TreeViewMain.SelectedNode = node
End Sub
Private Sub tstxtboxSearchNode_Click(sender As Object, e As EventArgs) Handles tstxtboxSearchNode.Click, tstxtboxSearchNode.Enter
tstxtboxSearchNode.Text = ""
End Sub