Occurs when a component's OLEDrag method is performed, or when a component initiates an OLE drag/drop operation when the OLEDragMode property is set to Automatic.
This event specifies the data formats and drop effects that the source component supports. It can also be used to insert data into the DataObject object.
Syntax
Private Sub object_OLEStartDrag(data As DataObject, allowedeffects As Long)
The OLEStartDrag event syntax has these parts:
Part | Description |
object | An object expression that evaluates to an object in the Applies To list. |
data | A DataObject object containing formats that the source will provide and, optionally, the data for those formats. If no data is contained in the DataObject, it is provided when the control calls the GetData method, and you should provide the values for the data parameter. The SetData and Clear methods cannot be used here. |
allowedeffects | A long integer containing the effects that the source component supports. The possible values are listed in Settings. |
Settings
The settings for allowedeffects are:
Constant | Value | Description |
vbDropEffectNone | 0 | Drop target cannot accept the data. |
vbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation. |
vbDropEffectMove | 2 | Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move. |
Remarks
The source component should logically Or together the supported values and place the result in the allowedeffects parameter. The target component can use this value to determine the appropriate action, and what the appropriate user feedback should be.
The StartDrag event also occurs if the component’s OLEDragMode property is set to Automatic. This allows you to add formats and data to the DataObject object after the component has done so. You can also override the default behavior of the component by clearing the DataObject object (using the Clear method) and then adding your data and formats.
You may want to defer placing data into the DataObject object until the target component requests it. This allows the source component to save time by not loading multiple data formats. When the target performs the GetData method on the DataObject, the source’s OLESetData event will occur if the requested data is not contained in the DataObject. At this point, the data can be loaded into the DataObject, which will in turn provide the data to the target.
If the user does not load any formats into the DataObject, then the drag/drop operation is canceled.