title: How to send textfile string to textbox using listbox?
body: <p>The Windows Form application project I'm working on requires me to fill 4 textboxes with values in a text file.
  In the textfile, every line contains a word for each textbox, separated by a space. (For example, the first line could say "cat fish dog horse" and the second line could say "a b c d")</p>
  
  <p>The listbox contains the first word of every line. (Running with the same example, the list box will contain "cat" and "a".)</p>
  
  <p>So I'll double click on a value in the listbox, and run a search in the textfile using streamreader, select the line that contains the selected item, place it in a string array, split it into 4 elements based on the spacing, and place them into the 4 respective textboxes.</p>
  
  <p>It doesn't work right yet though, any suggestions?</p>
  
  <pre><code>       private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)//list double click
      {
          AccountBox.Clear();
          EmailBox.Clear();
          UserBox.Clear();
          PassBox.Clear(); //to reset boxes
  
          string accountName = listBox1.GetItemText(listBox1.SelectedItem);
          AccountBox.Text = accountName;
  
          System.IO.StreamReader account = new System.IO.StreamReader("record.txt");
  
          var lineCount = File.ReadLines("record.txt").Count(); 
          int lines = Convert.ToInt32(lineCount);
          for (int i = 0; i &lt; lines; i++)
  
         {
          if (account.ReadLine().Contains(AccountBox.Text))
              {
                  string[] words;
  
                  words = account.ReadLine().Split(' ');
  
                  AccountBox.Text = words[0];
                  EmailBox.Text = words[1];
                  UserBox.Text = words[2];
                  PassBox.Text = words[3]; 
              }
              else
              {
                  break;
              }
          }
  </code></pre>