Thank you! Works just fine!!
When we are talking about drag and drop function i can explain my other problem.
I´m trying to make a drag and drop function beetween listviews. I just wanna copy the item to the other, dont remove. And the copy fuction doesn´t bring the subitems,
private void listView1_MouseDown(object sender, MouseEventArgs e)
foreach (ListViewItem SelectedName in listView1.SelectedItems)
DragDropEffects.Move);
private void listView2_DragDrop(object sender, DragEventArgs e)
DataFormats.Text).ToString());
private void listView2_DragEnter(object sender, DragEventArgs e)
if (e.Data.GetDataPresent(DataFormats.Text))
DragDropEffects.Move;
else
DragDropEffects.None;
One question per thread please. Several problems, you can only start on DoDragDrop() at a time. And you're only dragging a string. Here's the way to do it:
private void listView1_ItemDrag(object sender, ItemDragEventArgs e) {
listView1.DoDragDrop(listView1.SelectedItems, DragDropEffects.Copy);
}
private void listView2_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetData(typeof(ListView.SelectedListViewItemCollection)) != null)
e.Effect = DragDropEffects.Copy;
}
private void listView2_DragDrop(object sender, DragEventArgs e) {
ListView.SelectedListViewItemCollection coll =
(ListView.SelectedListViewItemCollection)e.Data.GetData(typeof(ListView.SelectedListViewItemCollection));
foreach (ListViewItem item in coll)
listView2.Items.Add((ListViewItem)item.Clone());
}