Enabling Automatic OLE Drag and Drop

See Also

If your controls support automatic dragging and dropping, you can drag data from and/or drop data into a Visual Basic control by setting the control’s OLEDragMode and/or OLEDropMode properties to Automatic. For instance, you may want to drag text from a text box control into a Word for Windows document, or allow the text box control to accept data dragged from the Word for Windows document.

To allow dragging from the text box control, set the OLEDragMode property to Automatic. At run time, you can select text typed into the text box control and drag it into the open Word for Windows document.

When you drag text from the text box control into a Word for Windows document, it is, by default, moved rather than copied into the document. If you hold the CTRL key down while dropping text, it will be copied rather than moved. This is the default behavior for all objects or applications that support OLE drag-and-drop. To restrict this operation by allowing data to only be moved or only be copied, you need to modify the automatic behavior by using the manual dragging and dropping techniques. For more information, see "Using the Mouse and Keyboard to Modify Drop Effects and User Feedback."

To allow the text box control to automatically retrieve data in a OLE drag-and-drop operation, set its OLEDropMode property to Automatic. At run time, data dragged from an OLE-enabled application into the text box control will be moved rather than copied unless you hold down the CTRL key during the drop, or alter the default behavior through code.

Automatic support for dragging and dropping data has its limitations; some of these limitations are derived from the functionality of the controls themselves. For instance, if you move text from a Word for Windows document into a text box control, all the rich text formatting in the Word document will be stripped out because the text box control doesn’t support this formatting. Similar limitations exist for most controls. Another limitation of automatic operations is that you don't have complete control over what kind of data is dragged and/or dropped.

Note   When dragging data, you may notice that the mouse pointer indicates if the object that it is passing over supports OLE drag and drop for the type of data that you are dragging. If the object supports OLE drag and drop for the type of data, the “drop” pointer is displayed. If the object does not, a "no drop" pointer is displayed.