title: Images in treeview nodes/subnodes
body: <p>I'm using a treeview with this structure</p>
  
  <p><img src="https://i.stack.imgur.com/ZVeSa.jpg" alt="enter image description here"></p>
  
  <p>I have to add an image for every SUB-SUBCHILD that represents tha data type (int, char, etc...) but it works in a strange way...</p>
  
  <p>image1 is the "char" image instead of "int"
  image2 is the "char" image
  image3 is the "double" image instead of "char"
  image4 is the default (index 0) image  instead of "double"</p>
  
  <p>The last SUB-SUBCHILD is alway different than the expected!</p>
  
  <p>In the debug mode the imagelist index value is what I expected to see, but in the treeview no.</p>
  
  <p>Why?</p>
  
  <p>This is my code:</p>
  
  <pre><code>    private void createTree(string[,] strArrLF3) //strArrLF3 matrix of n ROWS and 11 COLS
      {
          int counter = 0;
          Int32 arrayLen = 0;
  
          arrayLen = (strArrLF3.Length) / 11;
  
          trvSimulations.ImageList = imgListRes;  //trvSimulation is the name of treeview
  
          TreeNode ParentNode = new TreeNode();
          ParentNode.Text = "Root";
          ParentNode.ForeColor = Color.Black;
          ParentNode.BackColor = Color.White;
  
          ParentNode.ImageIndex = 0;
          ParentNode.SelectedImageIndex = 0;
          trvSimulations.Nodes.Add(ParentNode);         //Root node
  
          TreeNode trvChild_ATSM0 = new TreeNode();
          trvChild_ATSM0.Text = "CHILD1";
          trvChild_ATSM0.ForeColor = Color.Black;
          trvChild_ATSM0.BackColor = Color.White;
          trvChild_ATSM0.ImageIndex = 1;
          trvChild_ATSM0.SelectedImageIndex = 1;
          ParentNode.Nodes.Add(trvChild_ATSM0);         //CHILD1 node (child of Root node)
  
          TreeNode chdIN_ATSM0 = new TreeNode();
          chdIN_ATSM0.Text = "Input Signals";
          chdIN_ATSM0.ForeColor = Color.Black;
          chdIN_ATSM0.BackColor = Color.White;
          chdIN_ATSM0.ImageIndex = 3;
          chdIN_ATSM0.SelectedImageIndex = 3;
          trvChild_ATSM0.Nodes.Add(chdIN_ATSM0);         //Input node (child of  CHILD1)
  
          TreeNode chdOUT_ATSM0 = new TreeNode();
          chdOUT_ATSM0.Text = "Output Signals";
          chdOUT_ATSM0.ForeColor = Color.Black;
          chdOUT_ATSM0.BackColor = Color.White;
          chdOUT_ATSM0.ImageIndex = 2;
          chdOUT_ATSM0.SelectedImageIndex = 2;
          trvChild_ATSM0.Nodes.Add(chdOUT_ATSM0);         //Output node (child of  CHILD1)
  
          TreeNode sub_chdIN_ATSM0 = new TreeNode(), sub_chdOUT_ATSM0 = new TreeNode();
  
          counter = 0;
          int imagePos = 0;
          for (counter = 0; counter &lt; arrayLen; counter++)
          {
              string signal = strArrLF3[counter, 9]; //matrix column containing a string ("int", "char", "long", "double")
              imagePos = imageSigType(signal);  //function containing a SWITCH/CASE that return an integer value (index of imagelist) 
              if (strArrLF3[counter, 0] == "CHILD1")
              {
                  if (strArrLF3[counter, 8] == "I")
                  {
                      sub_chdIN_ATSM0.ImageIndex = imagePos;
                      sub_chdIN_ATSM0.SelectedImageIndex = imagePos;
                      sub_chdIN_ATSM0 = chdIN_ATSM0.Nodes.Add(strArrLF3[counter, 1]);
                  }
                  else if (strArrLF3[counter, 8] == "O")
                  {
                      sub_chdOUT_ATSM0.ImageIndex = imagePos;
                      sub_chdOUT_ATSM0.SelectedImageIndex = imagePos;
                      sub_chdOUT_ATSM0 = chdOUT_ATSM0.Nodes.Add(strArrLF3[counter, 1]);
                  }
              }
          }
      }
  </code></pre>
  
  <p>Thanks</p>