Wednesday, April 18, 2012

Windows form with list views, dragging and dropping, need source list view

Using VS 2008 I have a windows form with 2 ListViews (we will call them ListView1 and ListView2). ListView1 is populated with FileNames from a directory. When an item is dragged from ListView1 to ListView2 I have some code that is executed. When I dragDrop from ListView2 to ListView1 some code executes. What I want to do is NOT execute the code if you dragdrop from ListView2 onto itself



Here is the dragDrop Method which is invoked after a drop:



private void view_DragDrop(object dropTarget, DragEventArgs e)



I have tried a few items such as below:



ListView data = (ListView)e.Data.GetData("System.Windows.Forms.ListView")



This returns null what I wanted to do with the above is see if data = dropTarget, do not execute.





No comments:

Post a Comment