The FileList Control’s DragDrop Event Handler

There are a few more lines of code here because the program must figure out the control that initiated the drag-and-drop operation and remove the selected item from the corresponding list. Again, the code uses the form’s ActiveControl property to figure out where the item came from.

You may notice that the DragLabel control doesn’t become visible before the Drag method is called. Its outline is dragged as if it was vi~ible. Normally, you wouldn’t be able to drag an invisible control, but the Drag method doesn’t seem to care about the control’s Visible property

If you open the ListDrop application on the CD, you will see that the controls that don’t react to the dropping of the control have the following code in their DragOver event:

The controls that can’t be used as destinations for the drag-and-drop operationreact to the DragOver event by setting the pointer to a stop icon, to  indicate that they are not valid receptors for the current operation. It is customary to include thes; two lines of code in all the controls that won’t react to the DragDrop event.

Scroll to Top