I need to do drag and drop using treeview in c#.For that i heard 3 events are the most common 1.itemDrag 2.DragDrop and 3.DragEnter.
whereas here itemDrag event is firing for me while dragging from a treeview ,but rest both the events are not firing for me.Tried many solutions and now came here for an solution
private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
{
string[] strItem = e.Item.ToString().Split(':');
DoDragDrop(strItem[1], DragDropEffects.Copy | DragDropEffects.Move); }
the above method fires ,
private void treeView1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
the bove dragEnter event is not firing ,similarly the dragDrop event is also not firing.Why it's so??
Am dragging from the treeview and need to paste in PowerPoint or Word. (ie) treeview is something like an AddIn for Office Tools.
Regards, Arshad
Allow Drop AND..
Ok, assuming you have all of your events being declared/created in the Form_Load... e.i. :
The drag Event is for when you fire the drag event inside your treeView which is why it is working. The dragEnter is when you enter the boundaries of a different* control.
i.e you want to drag from treeview 1 into treeview2.
If you are not trying to drag the item into a different control dragEnter is wrong.
Here is a drag drop event sample :
} Not sure if it is possible but you may want to change the dragEnter code you have and simply use it in the drag event i.e.
If you are not leaving the same control you are dragging both to and fro, might as well show the drag movement.
Another thing you could do is on the treeView_MouseMove Event.