title: Populate TreeView from another class (or something better?) C#
body: <p>I'm trying to make a level reader application for one of my favourite games, and simply put this is what I'm trying to achieve currently:</p>
  
  <p>First 8 bytes of level file:</p>
  
  <pre><code>0100000001000000
  </code></pre>
  
  <p>It states that the mesh version = 1 and vertex version = 1.</p>
  
  <p>I've made a GUI in which I have a treeview, and in the tree it has header, and in header it has vertex and mesh version. I would like to populate these with this data.</p>
  
  <p>Now this is where my first problem arises:<br>I want to have all my reading done in its own class (for example, HeaderData, MaterialData), etc, just to make the code cleaner.
  Because I'm doing this in another class, <br>I have NO idea how I can access my treeview from said class (if I were in the Form class I could just do treeView1.whatever, but I don't know how to access it from another class. <br><br>Note: I've tried Levelreader.Form1.treeView1, but it doesn't exist).</p>
  
  <pre><code>public void button1_Click(object sender, EventArgs e)
  {
      using (OpenFileDialog fileDialog = new OpenFileDialog())
      {
          if (fileDialog.ShowDialog() != DialogResult.Cancel)
          {
              textBox1.Text = fileDialog.FileName;
              using (BinaryReader fileBytes = new BinaryReader(new MemoryStream(File.ReadAllBytes(textBox1.Text))))
              {
                  //Get the hex data in bytearray format
                  //This won't be displayed
                  int length = (int)fileBytes.BaseStream.Length;
                  byte[] hex = fileBytes.ReadBytes(length);
                  //File.WriteAllBytes(@"c:\temp_file.txt", hex);
  
                  //This is what's displayed.
                  //Remember to make changes to the byte array
                  //and then update the view.
                  string tempStr = BitConverter.ToString(hex).Replace("-", " ");
                  richTextBox1.Text = tempStr;
                  richTextBox1.ScrollBars = RichTextBoxScrollBars.ForcedVertical;
  
                  //Instantiate the class
                  Header temp = new Header();
                  temp.HeaderData(hex);
                  }
              }
          }
  
      }
  </code></pre>
  
  <p>This is the method, within the class Form1, in namespace LevelReader, that reads the file and then instantiates the class Header(). I then call HeaderData, and within that class I get the mesh and vertex version.</p>
  
  <pre><code>namespace SceneStuff
  {
      public class Header
      {
  
          public void HeaderData(byte[] hex)
          {
              //First 4 Bytes = Mesh Version
              //Second 4 Bytes = Vertex Version
              byte[] meshVersion = hex.Take(4).ToArray();
              byte[] vertexVersion = hex.Skip(4).Take(4).ToArray();
  
          }
  
      }
  }
  </code></pre>
  
  <p>in THIS method is where I want to use this data to populate my treeview. And say for example I changed some information in the level, such as changing the mesh version to 2, I want, when I press 'Compile Level' (in my apps GUI) to read from the TreeView, as I believe it would be best that way. However, if you have suggestions, please state them, as I'm new to c#!
  <br>
  <br>
  So in summary, here are my two problems:<br>
  1) How can I access my treeview from another namespace/class?<br>
  2) Do you have any suggestions to improve my code? (and the way I plan to compile my levels?)
  <br><br>
  Thanks!
  <br><br>
  P.S. I apologize for the wall of text! >_&lt;</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I have another problem which is that I can't seem to populate my node.</p>
  
  <p>It is created like this:</p>
  
  <pre><code>    private void InitializeComponent()
      {
          this.components = new System.ComponentModel.Container();
          System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Mesh Version");
  </code></pre>
  
  <p>and below:</p>
  
  <pre><code>        treeNode2.Name = "meshVersion";
          treeNode2.Text = "Mesh Version";
  </code></pre>
  
  <p>I've tried adding treeNode2 as a reference to my method, but that doesn't work.<br>
  I've tried to select it with <code>treeView1.SelectedNode = treeView1.Nodes[1].Nodes[1];</code> but that doesn't seem to work either. <br>(here is an image of the GUI, which shows that <code>Nodes[1].Nodes[1]</code> is, I think, what I'm trying to access (I'm trying to access Mesh Version) <a href="http://i.imgur.com/hahhG.png" rel="nofollow">http://i.imgur.com/hahhG.png</a><br><br>
  <br>
  So what I need to do is to access that PRE EXISTING NODE and add a child to it. I just can't seem to find any tutorials that detail it in these circumstances and I don't understand it will enough to cater their tutorials to suit my needs.</p>
  
  <p>Thanks so much.</p>