title: How to automatically play next item of a listBox
body: <p>I am using a listBox to play file from media player on my form, I am using the code below to get files in my listbox,as it retuns the file name, now I am able to play files from listBox  and now I want next item in the listbox to be played automatically after a time gap.How to do this</p>
  
  <pre><code>this.listBox1.DisplayMember = "Name";/*to display name on listbox*/
  this.listBox1.ValueMember = "FullName";/*to fetch item value on listbox*/
  listBox1.DataSource = GetFolder("..\\video\\"); /*gets folder path*/ 
  
  private static List&lt;FileInfo&gt; GetFolder(string folder)
  {
      List&lt;FileInfo&gt; fileList = new List&lt;FileInfo&gt;();
  
      foreach (FileInfo file in new DirectoryInfo(folder)
                                   .GetFiles("*.mpg",SearchOption.AllDirectories))
      {
          fileList.Add(file);
      }
  
      return fileList;
  }
  </code></pre>
  
  <p>for listbox I am using the following code</p>
  
  <pre><code>private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
  {     
      Player.URL = Convert.ToString(listBox2.SelectedItem);
  }
  </code></pre>
  
  <p>for listBox1 I am using the code</p>
  
  <pre><code>    private void listBox1_SelectedIndexChanged(object sender, EventArgs e )
      {
  
          StreamWriter sw = new StreamWriter("..\\Debug\\List.txt", true);
          //Player.URL = Convert.ToString(listBox1.SelectedItem);
          string selectedItem = listBox1.Items[listBox1.SelectedIndex].ToString();
  
  
          //listView1.Items.Add(listBox1.SelectedItem.ToString());
  
          foreach (object o in listBox1.SelectedItems)
              sw.WriteLine(DateTime.Now + " - " + o);
  
          sw.Close();
  
  
      }
  </code></pre>
  
  <p>Then I am using a button to transfer selected listbox1 files to listBox2 on another form</p>
  
  <pre><code>   private void button1_Click_1(object sender, EventArgs e)
      {
  
          System.Text.StringBuilder sb = new System.Text.StringBuilder();
          foreach (object item in listBox1.Items)
          {
              sb.Append(item.ToString());
              sb.Append(" ");
  
          }
  
  
         string selectedItem = listBox1.Items[listBox1.SelectedIndex].ToString();
  
  
              //listBox2.Items.Add(listBox1.SelectedItem.ToString());
              Form3 frm = new Form3();
  
              foreach (int i in listBox1.SelectedIndices)
              {
  
                      frm.listBox2.Items.Add(listBox1.Items[i].ToString());
  
  
                  frm.Show();
                  this.Hide();
  
              }
  
          }
  </code></pre>
  
  <p>listbox2 code is mentioned above.</p>