title: moving items from one listbox to another c# windows application
body: <p>I have 2 listboxes in my application.  The data is being retrieved from a SQL server database.  In listbox1, I want to select few items from this listbox and add them to second one through add button.</p>
  
  <p>PROBLEM:
  The values are being retrieved from the database but when I click the add button after selecting a value from listbox1, System.Data.DataRowView is displayed in listbox2 automatically.</p>
  
  <p>Listbox2 is not currently connected to any databse.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>for (int i = 0; i &lt; listBox1.Items.Count; i++)
  {
      listBox2.Items.Add(listBox1.Items[i]);
      listBox1.Items.Remove(listBox1.SelectedItem);
  }
  </code></pre>
  
  <p>I have also tried using this:</p>
  
  <pre><code>for (int i = 0; i &lt; from.SelectedItems.Count; i++)
  {
      to.Items.Add(from.SelectedItems[i].ToString());
  }
  
  foreach (var item in new ArrayList(from.SelectedItems))
  {
      from.Items.Remove(item);
  }
  </code></pre>
  
  <p>From and to are listbox1 and listbox2 respectively.</p>
  
  <p>Any help would be appreciated.</p>