The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

  • Advertisements

Recursive loop treeview control

Posted by Clayton James on May 27, 2010

I am doing some work with the treeview control for displaying and selecting rooms in applications. When working with the treeview control you usually don’t know how many different levels of nodes you may be working with. Here are a couple of methods that will loop through all nodes in your treeview control.

private void RecurseNodes()
   foreach (TreeNode parentNode in locationsTreeView.Nodes)
    if (parentNode.ChildNodes.Count > 0)

  private void RecurseChildren(TreeNode tn)
   if (tn.ChildNodes.Count > 0)
    tn.SelectAction = TreeNodeSelectAction.None;
    foreach (TreeNode tnC in tn.ChildNodes)


One Response to “Recursive loop treeview control”

  1. Alanna said

    Hi it’s me, I am also visiting this site daily, this web page is truly good and the viewers are truly sharing
    pleasant thoughts.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: