title: How to Remove selected item from listbox C#
body: <p>i currently trying to view all the files and folder selected by the user in a listbox. At the Moment i am able to list what the user have chosen using the openfiledialogue HOWEVER i am now facing prob when i try to remove it form the listbox. i trying to allow the user to click on the checkbox beside the file and press the remove button to remove it</p>
  
  <p>this is my code for remove button</p>
  
  <pre><code>      private void button2_Click(object sender, EventArgs e)
      {
          for (int i = listView1.SelectedItems.Count - 1; i &gt;= 0; i--)
          {
              listView1.Items.Remove(listView1.SelectedItems[i]);
          }
  
      }
  </code></pre>
  
  <p>this is the add file to listbox for reference jsut in case</p>
  
  <pre><code>    private void button1_Click(object sender, EventArgs e)
      {
  
          OpenFileDialog openfiledialog = new OpenFileDialog();
          // Display open file dialog
          openfiledialog.InitialDirectory = "C:\\";
          //openfiledialog.Multiselect = true;
          openfiledialog.Title = "Lock File";
          openfiledialog.Filter = "All Files | *.*";
          openfiledialog.ShowDialog();
  
  
          if (openfiledialog.FileName != "")
          {
  
          //move through FileInfo array and store in new array of fi
              listView1.Items.Clear();
              foreach (string file in openfiledialog.FileNames)
              {
                  listView1.Items.Add(file);
              }        
          }
  
      }
  </code></pre>
  
  <p>and i pressed the remove button nothing happen and i saw some answer on google on the using of selectionmode but when i used that, my listbox does not have the property of selectionmode and have red lines underlined</p>