Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Heres the solution:</p> <p><strong><em>WORKING and TESTED:</em></strong></p> <pre><code> public void selectTreeNodeFromPath(string path) { // set up some delimters to split our path on. char[] delimiters = new char[] { '\\' }; // split the array and store the values inside a string array. string[] pathArray = path.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); // clean up this array. ensurePathArrayAccuracy(ref pathArray); // a simple celing variable. int numberOfLvlsToProbe = pathArray.Length; // a variable for to keep an eye on the level of the TreeNode. int currentLevel = 0; // this collection always get re-populated each iteration. TreeNodeCollection globalTreeNCollection = treeDrives.Nodes; do { // start iterating through the global tree node collection. foreach (TreeNode rootNode in globalTreeNCollection) { // only set the level if the node level is less! if (rootNode.Level &lt; pathArray.Length) { currentLevel = rootNode.Level; // the 'currentLevel' variable can also be used to help index the 'pathArray' to make comparisons straightforward with current node. if (rootNode.Text == pathArray[currentLevel]) { // update our control variables and start again, the next level down. globalTreeNCollection = rootNode.Nodes; // once we have found the node then ... break; } } else // this portion of code means we are at the end of the 'pathArray.' { treeDrives.SelectedNode = rootNode; //treeDrives.SelectedNode.EnsureVisible(); // to make sure the loop ends ... we need to update the currentLevel counter // to allow the loop to end. currentLevel = numberOfLvlsToProbe; break; } } } // if the 'currentLevel' is less than the 'numberOfLvlsToProbe' then we need // to keep on looping till we get to the end. while (currentLevel &lt; numberOfLvlsToProbe); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload