Drag'n Drop from ListViewControl
-
Hi, I'm trying to implement a drag'n drop from a multiselect listView to a tree. The code is as follows: private void listView1_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) { listView1.DoDragDrop(listView1.SelectedItems, DragDropEffects.Copy); } private void treeView1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection))) e.Effect = DragDropEffects.Copy; } private void treeView1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //do something here } Everything is fine, except that a lot of times the list thinks I'm trying to select items instead of initiating a drag'n drop. Is there a listView setting I'm missing somehow? thanx
-
Hi, I'm trying to implement a drag'n drop from a multiselect listView to a tree. The code is as follows: private void listView1_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) { listView1.DoDragDrop(listView1.SelectedItems, DragDropEffects.Copy); } private void treeView1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection))) e.Effect = DragDropEffects.Copy; } private void treeView1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //do something here } Everything is fine, except that a lot of times the list thinks I'm trying to select items instead of initiating a drag'n drop. Is there a listView setting I'm missing somehow? thanx
kozu wrote:
except that a lot of times the list thinks I'm trying to select items instead of initiating a drag'n drop
By any chance are you using "Full Row Select" mode? I've learned that often triggers that behavior. What I did was that when I initiate Drag Drop on the ListView, I turn off FullRowSelect. This has the added benefit of allowing the user to select multiple items and then DE-select them by clicking a non-highlighted area (with full row select, that can be hard to do if there is no non-highlighted space). When the drag operation ends, or they de-select the items, I turn it back on.
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein