DragDrop event
The DragDrop event has different arguments for different
objects:
Object |
See |
---|---|
ListBox, PictureListBox, ListView, and Tab |
|
TreeView control |
|
Windows and other controls |
For information about the DataWindow control’s DragDrop
event, see the DataWindow Reference or the online Help.
Syntax 1 For ListBox, PictureListBox, ListView, and Tab controls
Description
Occurs when the user drags an object onto the control and
releases the mouse button to drop the object.
Event ID
Event ID |
Objects |
---|---|
pbm_lbndragdrop |
ListBox, PictureListBox |
pbm_lvndragdrop |
ListView |
pbm_tcndragdrop |
Tab |
Parameters
Argument |
Description |
---|---|
source |
DragObject by value (a reference to the |
index |
Integer by value (the index of the target |
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Continue
processing
Usage
Obsolete functions
You no longer need to call the DraggedObject function
in a drag event. Use the source argument instead.
Examples
For ListView controls, see the example for BeginDrag.
This example inserts the dragged ListView item:
1 |
This.AddItem(ilvi_dragged_object) |
1 |
This.Arrange( ) |
See Also
Syntax 2 For TreeView controls
Description
Occurs when the user drags an object onto the control and
releases the mouse button to drop the object.
Event ID
Event ID |
Objects |
---|---|
pbm_tvndragdrop |
TreeView |
Parameters
Argument |
Description |
---|---|
source |
DragObject by value (a reference to the |
handle |
Long by value (the |
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Continue
processing
Usage
Obsolete functions
You no longer need to call the DraggedObject function
in a drag event. Use the source argument instead.
Examples
This example inserts the dragged object as a child
of the TreeView item it is dropped upon:
1 |
TreeViewItem ltv_1 |
1 |
This.GetItem(handle, ltv_1) |
1 |
This.SetDropHighlight(handle) |
1 |
This.InsertItemFirst(handle, itvi_drag_object) |
1 |
This.ExpandItem(handle) |
1 |
This.SetRedraw(TRUE) |
See Also
Syntax 3 For windows and other controls
Description
Occurs when the user drags an object onto the control and
releases the mouse button to drop the object.
Event ID
Event ID |
Objects |
---|---|
pbm_bndragdrop |
CheckBox, CommandButton, Graph, InkEdit, |
pbm_cbndragdrop |
DropDownListBox, DropDownPictureListBox |
pbm_dragdrop |
DatePicker, MonthCalendar |
pbm_endragdrop |
SingleLineEdit, EditMask, MultiLineEdit, |
pbm_omndragdrop |
OLE |
pbm_prndragdrop |
HProgressBar, VProgressBar |
pbm_rendragdrop |
RichTextEdit |
pbm_sbndragdrop |
HScrollBar, HTrackBar, VScrollBar, VTrackBar |
pbm_uondragdrop |
UserObject |
pbm_dragdrop |
Window |
Parameters
Argument |
Description |
---|---|
source |
DragObject by value (a reference to the |
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Continue
processing
Usage
When a control’s DragAuto property is true,
a drag operation begins when the user presses a mouse button.
Obsolete functions
You no longer need to call the DraggedObject function
in a drag event. Use the source argument instead.
Examples
In this example, the code in the DoubleClicked event for the DataWindow dw_orddetail starts
a drag operation:
1 |
IF dw_orddetail.GetRow() > 0 THEN |
1 |
   dw_orddetail.Drag(Begin!) |
1 |
   This.DragIcon = "dragitem.ico" |
1 |
END IF |
Then, in the DragDrop event for a trashcan Picture
control, this code deletes the row the user clicked and dragged
from the DataWindow control:
1 |
long ll_currow |
1 |
dwitemstatus ldwis_delrow |
1 |
1 |
ll_currow = dw_orddetail.GetRow( ) |
1 |
1 |
// Save the row's status flag for later use |
1 |
ldwis_delrow = dw_orddetail.GetItemStatus & |
1 |
   (ll_currow, 0, Primary!) |
1 |
1 |
// Now, delete the current row from dw_orddetail |
1 |
dw_orddetail.DeleteRow(0) |
This example for a trashcan Picture control’s DragDrop
event checks whether the source of the drag operation is a DataWindow.
If so, it asks the user whether to delete the current row in the
source DataWindow:
1 |
DataWindow ldw_Source |
1 |
Long ll_RowToDelete |
1 |
Integer li_Choice |
1 |
1 |
IF source.TypeOf() = DataWindow! THEN |
1 |
1 |
   ldw_Source = source |
1 |
   ll_RowToDelete = ldw_Source.GetRow() |
1 |
1 |
   IF ll_RowToDelete > 0 THEN |
1 |
      li_Choice = MessageBox("Delete", & |
1 |
      "Delete this row?", Question!, YesNo!, 2) |
1 |
      IF li_Choice = 1 THEN |
1 |
      ldw_Source.DeleteRow(ll_RowToDelete) |
1 |
      END IF |
1 |
   ELSE |
1 |
      Beep(1) |
1 |
   END IF |
1 |
1 |
ELSE |
1 |
   Beep(1) |
1 |
END IF |