title: Clearing Multi-Selected Items From Listbox C#
body: <p>What i've tried:</p>
  
  <p>try 1:</p>
  
  <pre><code>for(int x = listBox1.SelectedIndices.Count - 1; x&gt;= 0; x--)
  { 
      int idx = listBox1.SelectedIndices[x];
      listBox2.Items.Add(listBox1.Items[idx]); 
      listBox1.Items.RemoveAt(idx);
  } 
  </code></pre>
  
  <p>try 2:</p>
  
  <pre><code>ArrayList tmpArr = new ArrayList();
  foreach (object obj in listBox1.SelectedItems)
  {
      listBox2.Items.Add(obj);
      tmpArr.Add(obj);
  }
  foreach (object obj in tmpArr.ToArray())
  {
      listBox1.Items.Remove(obj);
  }
  </code></pre>
  
  <p>Also tried everything in the following post: <a href="https://stackoverflow.com/questions/9483187/how-to-remove-multiple-selected-items-in-listbox">How to remove multiple selected items in ListBox?</a></p>
  
  <p>Still nothing worked. What am I doing wrong?</p>