Hallo Ich verwende das Microsoft Treeview control Versin 6.0. Der code sucht einen Knoten in meinem Treeview. Die Fehlermeldung erscheint ab und zu bei erreichen der rot markierten Zeile. An der grün markierte Stelle mLastNodeFound.Text <> "Kategorien" hat die Variable mLastNodeFound noch einen Wert. Kann mir jemand von euch hier helfen?
Public Function FindInputStringInTree(ByVal FindPath As String, ByVal objTreeView As treeView) As Boolean 'Find a node in Treeview by it's FullPath, expand and highlight it. 'FindPath ...... Fullpath to search for. 'ObjTreeView ... Treeview Object.
Dim knoten As MSComctlLib.Node
On Error GoTo err_FindInputStringInTree 'Start error handling.
For Each knoten In objTreeView.Nodes 'Loop through nodes.
If knoten.FullPath = FindPath Then 'Category path found. Call CollapseTreeViewNodes(objTreeView) 'Collapse al nodes. Set mLastNodeFound = knoten 'Save found node. knoten.Selected = True 'Select node. knoten.EnsureVisible 'Show selected node. knoten.Expanded = True 'Expand node. knoten.BackColor = vbRed 'Show node found red knoten.Parent.Selected = True 'Select parent node. FindInputStringInTree = True 'Path found. Exit For 'Leave each loop. End If Next If Not mLastNodeFound Is Nothing Then 'Path not found and nodetext is not KATEGORIEN. If FindInputStringInTree = False And mLastNodeFound.Text <> "Kategorien" Then Call CollapseTreeViewNodes(objTreeView) 'Collapse all nodes. mLastNodeFound.Selected = True 'Select node. mLastNodeFound.Expanded = False 'Expand selected node. mLastNodeFound.Parent.Selected = True 'Select parent node. Set mLastNodeFound = Nothing 'Clear object variable End If End If res_FindInputStringInTree: 'Point of resume application.
Exit Function
err_FindInputStringInTree: Select Case Err.Number Case Else MsgBox "Ein unbekannter Fehler ist aufgetreten." & g2CrLf & "Fehler-Nr : " & _ Err.Number & gCrLf & "In Modul : Common - FindInputStringInTree" & _ g2CrLf & "Fehlertext : " & Err.Description, vbCritical Or vbOKOnly, " Unbekanter Fehler" Resume res_FindInputStringInTree 'Point of resume application.
End Select Danke und Gruß Julia.
|