none
Drag and drop into other applications RRS feed

  • Question

  • Hello,

    I want to make an WPF application where I can drag and drop strings into other applications...

    like:
    Ik want to drag a string ("test123") from a listbox in my application and then drop the string into another existing apllication like notepad, VS 2008,...

    Does anyone know how to start with this?
    I have no idea which event I have to fire...

    Thanks in advance
    Tuesday, April 14, 2009 6:07 PM

Answers

  • It should work basically the same. You put your string in a DataObject and it's up to the other program to handle it when you drop it. If it supports dropping of that type of data, it should work.
    For example, if I do something like this:

                DataObject dObj = new DataObject(typeof(string), "My String");
                DragDrop.DoDragDrop(MyBtn, dObj, DragDropEffects.All);
    Which I put in the MouseDown event of a button, I can click the button and drag the string into, for example, this textbox in Firefox and it'll insert "My String"

    My String

    Easy.
    • Marked as answer by 3sdg Saturday, April 18, 2009 1:59 PM
    Thursday, April 16, 2009 1:08 PM

All replies

  • nobody??
    Wednesday, April 15, 2009 3:42 PM
  • http://msdn.microsoft.com/en-us/library/ms742859.aspx    <- Start here

    Basically when you start the drag operation in your application you will need to create a DataObject object and put your string into it.
    There are several examples on MSDN and plenty more on the internet.


    Wednesday, April 15, 2009 4:41 PM
  • At the given link, there are some samples to drag a string from another application into your application. But what i try to do is the other way... From my application into another...

    I have searched a lot of sites with google, but none of these give me a correct answer or a correct code sample...
    can someone find one as well?


    thanks
    Thursday, April 16, 2009 9:50 AM
  • It should work basically the same. You put your string in a DataObject and it's up to the other program to handle it when you drop it. If it supports dropping of that type of data, it should work.
    For example, if I do something like this:

                DataObject dObj = new DataObject(typeof(string), "My String");
                DragDrop.DoDragDrop(MyBtn, dObj, DragDropEffects.All);
    Which I put in the MouseDown event of a button, I can click the button and drag the string into, for example, this textbox in Firefox and it'll insert "My String"

    My String

    Easy.
    • Marked as answer by 3sdg Saturday, April 18, 2009 1:59 PM
    Thursday, April 16, 2009 1:08 PM
  • the folowing link should help... it shows drag drop of images. should be able to extend to text

    http://blogs.msdn.com/llobo/archive/2008/02/26/drag-drop-library-updated.aspx
    Friday, April 17, 2009 3:22 PM
    Moderator