title: ListView.SelectedItems[0] Selection Error
body: <p>Why is my program returning the following error?  </p>
  
  <p>Please be specific thanks.</p>
  
  <p>PS: For whatever reason when there is only one item in the <code>listview</code> it works.</p>
  
  <blockquote>
    <p><strong>Error:</strong> InvalidArgument=Value of '1' is not valid for 'index'.  Parameter name: index</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>if(e.Control == true)
              {
                  try
                  {
                      string s = "";
                      string sCheck = "";
                      int select = 0;
                      int i = 0;
                      int position = 0;
  
                      if (i == 1)
                      {
                          i--;
                      }
  
                      if(select &gt;= 1)
                      {
                          do
                          {
                              select--;
                          } while (select &gt;= 1);
                      }
  
                      if (position &gt;= 1)
                      {
                          do
                          {
                              position--;
                          } while (position &gt;= 1);
                      }
  
                      foreach (object item1 in listView1.Items)
                      {
                          if (item1 == listView1.SelectedItems[select])
                          {
                              s = listView1.SelectedItems[select].Text;
                              sCheck = item1.ToString();
                              MessageBox.Show(item1.ToString());
  
                          }
                          else
                          {
                              select++;
                          }
                      }
                      string s1 = "";
  
  
                      foreach (object item in listView1.Items)
                      {
                          if (sCheck == item.ToString())
                          {
  
                              MessageBox.Show(item.ToString());
                              i++;
                              position++;
  
                          }
                          else
                          {
                              position++;
                          }
                      }
  
                      string s2 = listView1.Items.Count.ToString();
                      s1 = position.ToString();
  
                      if (i == 1)
                      {
                          string result = "Item: " + s + " || Position: " + s1 + " || Total Items: " + s2;
                          MessageBox.Show(result, "ListView Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                      }
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show("Select a Item");
                      MessageBox.Show(ex.Message);
  
                  }
  </code></pre>