943,856 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1395
  • C# RSS
Jan 12th, 2009
0

Dropping a DataObject from Win form to desktop.

Expand Post »
Hello there, I have created and application where the items in a ListView will be dragged and dropped over the desktop. So far, I was able to implement the drag but cannot drop the item. The function I used should be detected by windows but it cannot register the drop on the desktop. Here is my code:

C# Syntax (Toggle Plain Text)
  1. private void listview_ItemDrag(object sender, ItemDragEventArgs e){
  2. DataObject object = new DataObject()
  3. string f = listview.SelectedItems[0].Text;
  4. object.SetData(DataFormats.FileDrop, f);
  5. DoDragDrop(object, DragDropEffects.All);
  6. }

I can't find any article that could enlighten me. I've been stuck in this code for days now. What seems to be the problem?
Reputation Points: 7
Solved Threads: 2
Junior Poster
murderotica is offline Offline
171 posts
since Aug 2008
Jan 13th, 2009
0

Re: Dropping a DataObject from Win form to desktop.

Im guessing because your object doesnt contain a file, it contains a filename, and you cant just put a string object to desktop.

I googled found plenty of examples, which work - i would suggest you do the same.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jan 13th, 2009
0

Re: Dropping a DataObject from Win form to desktop.

You've been lucky with google my friend. I found 2 examples that adheres to my issue; one was dragging and dropping a url from a form to the desktop and the other was he gave the example that I'm using. Can you share to me the samples that you've found?
Reputation Points: 7
Solved Threads: 2
Junior Poster
murderotica is offline Offline
171 posts
since Aug 2008
Jan 13th, 2009
0

Re: Dropping a DataObject from Win form to desktop.

Well the first I found was a URL dropper, and he does a heck of a lot more than you've shown code for, including creating the file so it can be written to desktop.
While the file he writes is a shortcut, the principal is the same.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: saving arrays
Next Thread in C# Forum Timeline: C# Coding for Access Database In Server





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC