Welcome Guest Search | Active Topics | Sign In | Register

EO Tree Helper Function for Finding Nodes Options
aspnet_vb
Posted: Tuesday, August 12, 2008 4:45:31 PM

Rank: Member
Groups: Member

Joined: 5/20/2008
Posts: 12
I had a hard time finiding nodes so I wrote this and maybe EO should add to tree component.

The 2nd function is a recursive call to search entire tree not called directly by code in most cases.


Function FindNodeByValue(ByVal Tree As EO.Web.TreeView, ByVal inValue As String) As EO.Web.TreeNode

FindNodeByValue = Nothing
For Each tnode As EO.Web.TreeNode In Tree.Nodes

If Trim(inValue) = Trim(tnode.Value) Then
FindNodeByValue = tnode
Exit Function
End If
FindSubNodeByValue(tnode, inValue, FindNodeByValue)
If FindNodeByValue IsNot Nothing Then
Exit Function
End If

Next
End Function

Sub FindSubNodeByValue(ByVal Node As EO.Web.TreeNode, ByVal inValue As String, ByRef NodeRef As EO.Web.TreeNode)

For Each tnode As EO.Web.TreeNode In Node.SubGroup.Nodes
If Trim(inValue) = Trim(tnode.Value) Then
NodeRef = tnode
Exit Sub
End If
FindSubNodeByValue(tnode, inValue, NodeRef)
If NodeRef IsNot Nothing Then
Exit Sub
End If
Next
End Sub
eo_support
Posted: Wednesday, August 13, 2008 8:01:22 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
These two functions are very useful. Thanks for sharing in the forum!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.