You should read up on how to implement drag and drop (see here:
http://tinyurl.com/3xw7wtg[
^])
You're biggest problem is that the ItemDrag is only going to add the actual item that was clicked on, not all of the selected items.
So, you need to decide how you're going to get all of the items into the DataObject that is being dragged. Drag and drop can get very complicated.
I'll provide a simple example though. I created a form with a ListView, a button, and a checkbox. The button just opens up a new instance of the form. The checkbox says whether or not to copy the item (if not checked, it will be moved).
The ListView is populated with items in the Form's load event.
To start the drag, I do:
private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
{
listView1.DoDragDrop(listView1.SelectedItems,
checkBox1.Checked ? DragDropEffects.Copy : DragDropEffects.Move);
}
Then you have to handle the DragOver to set the effect.
private void listView1_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection)))
e.Effect = e.AllowedEffect;
}
Then, you handle the DragDrop
private void listView1_DragDrop(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection)))
{
if (e.Effect == DragDropEffects.Copy)
{
foreach (ListViewItem current in (ListView.SelectedListViewItemCollection)e.Data.GetData(typeof(ListView.SelectedListViewItemCollection)))
{
listView1.Items.Add((ListViewItem)current.Clone());
}
}
else
{
foreach (ListViewItem current in (ListView.SelectedListViewItemCollection)e.Data.GetData(typeof(ListView.SelectedListViewItemCollection)))
{
current.Remove();
listView1.Items.Add((ListViewItem)current);
}
}
}
}
The different methods you use will depend on what you're trying to do. If it's a simple ListViewItem with only text, you may want to just create a string array and add that.