c# wpf treeView return list of all nodes / Рекурсивный перебор элементов


  1. private void PrintRecursive(TreeNode treeNode)   
  2. {   
  3.    // Print the node.   
  4.    System.Diagnostics.Debug.WriteLine(treeNode.Text);   
  5.    MessageBox.Show(treeNode.Text);   
  6.    // Print each node recursively.   
  7.    foreach (TreeNode tn in treeNode.Nodes)   
  8.    {   
  9.       PrintRecursive(tn);   
  10.    }   
  11. }   
  12.    
  13. // Call the procedure using the TreeView.   
  14. private void CallRecursive(TreeView treeView)   
  15. {   
  16.    // Print each node recursively.   
  17.    TreeNodeCollection nodes = treeView.Nodes;   
  18.    foreach (TreeNode n in nodes)   
  19.    {   
  20.       PrintRecursive(n);   
  21.    }   
  22. }  

No comments:

Post a Comment

Note: only a member of this blog may post a comment.