title: Delete Items from ListView in C#
body: <p>I need to delete items from a <code>ListView</code>, the code I am looking for will show a MessageBox to confirm and if no item is selected it will show an error MessageBox</p>
  
  <p>This is my code and it is not working :(</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
  {
      if (listView1.SelectedItems != null)
      {
          var confirmation = MessageBox.Show(
              "Voulez vous vraiment supprimer les stagiaires séléctionnés?",
              "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Question
          );
  
          if (confirmation == DialogResult.Yes)
          {
              for (int i = 0; i &lt; listView1.Items.Count; i++)
              {
                  if (listView1.Items[i].Selected)
                  {
                      listView1.Items[i].Remove();
                      i--;
                  }
              }
          }
      }
      else
      {
          MessageBox.Show("aucin stagiaire selectionnes", "erreur",
              MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
  }
  </code></pre>
  
  <p>The error is not in delete but, in <code>MessageBox's</code> I have two <code>MessageBox's</code>, error must be shown first before confirmation.</p>