|
-
Dec 13th, 2007, 04:54 AM
#1
Thread Starter
PowerPoster
Recursive method help
I am trying to go through each and every single treenode in a treeview.
I want to be able to return a treenode, or null, if a specific object has been found. how can I do this? I feel like i've lost all my knowledge!
private TreeNode GetObjectFromTreeView(TreeNode startingNode, MyObject objectToMatch)
{
foreach(TreeNode currentNode in startingNode.Nodes)
{
if (currentNode.Tag != null && currentNode.Tag.GetType() == typeof(MyObject))
{
return currentNode;
}
return this.GetObjectFromTreeView(currentNode, objectToMatch);
}
return null;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|