title: Move selected items from one listbox to another in C# winform
body: <p>I'm trying to move selected items in list box1 to list box2, and vice versa. I have two buttons, <code>&gt;&gt;</code> and <code>&lt;&lt;</code>. When I select items in listbox1 and then click on <code>&gt;&gt;</code> the items should move from listbox1 to listbox2.</p>
  
  <pre><code>private void MoveListBoxItems(ListBox source, ListBox destination)
  {
      ListBox.SelectedObjectCollection sourceItems = source.SelectedItems;
      foreach (var item in sourceItems)
      {
          destination.Items.Add(item);
      }
      while (source.SelectedItems.Count &gt; 0)
      {
          source.Items.Remove(source.SelectedItems[0]);
      }
  }
  
  private void button2_Click_1(object sender, EventArgs e)
  {
      MoveListBoxItems(listbox , lstActivity);
  }
  </code></pre>