Performing Drag-and-Drop Operations Between Applications
Performing drag-and-drop operations between applications is no different than enabling this action within an application, as long as both applications involved behave according to the "contract" established between the AllowedEffect and Effect properties.
In the example below, you will use a Windows application you create and the WordPad word processor that is included with the Windows operating system to illustrate drag-and-drop operations between applications. WordPad has a certain set of allowed effects for text being dragged and dropped; the Windows application you will write code for will work with these effects so that drag-and-drop operations may be completed successfully.
To perform a drag-and-drop procedure between applications
- Create a new Windows application. For more information, see Creating a Windows Application Project.
- Drag a TextBox control to your form from the Toolbox.
- Configure the TextBox control to receive dropped data. For more information, see Performing Drag-and-Drop Operations in Windows Forms.
- Press F5 to run the Windows application. While it is running, run WordPad.
WordPad is a text editor installed by Windows that allows drag-and-drop operations. It is accessible by pressing the Start button, selecting Run, and then typing WordPad into the text box of the Run dialog box and clicking OK.
Once WordPad is open, type a string of text into it. Using the mouse, select the text, and then drag the selected text over to the TextBox control in your Windows application. Notice, when you mouse over the TextBox control (and, consequently, raise the DragEnter event), the cursor changes, and you can drop the selected text into the TextBox control.
Additionally, you can configure your TextBox control to allow text strings to be dragged and dropped into WordPad. For more information, see Performing Drag-and-Drop Operations in Windows Forms.