Where does DragDrop event come from???

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

How do I find out what control a DragDrop event comes from? I initially
presumed that it was the "sender" parameter. But this always seems to be
the destination.

Ie ...

private void listviewMonday_DragDrop (object sender,
System.Windows.Forms.DragEventArgs e)
{
// "sender" always seems to point to "listviewMonday" here.
}


Thanks for any help,
Dan.
 
Dan said:
How do I find out what control a DragDrop event
comes from? I initially presumed that it was the
"sender" parameter. But this always seems to be
the destination.

You can control the data that is passed in a drag operation. If you
want to know the source control, pass a reference to that control as
the data.

P.
 
How do I find out what control a DragDrop event
You can control the data that is passed in a drag operation. If you
want to know the source control, pass a reference to that control as
the data.


Hi. How do I do this? The only place that my DragDrop function is
referenced in code is:

"this.listviewMonday.DragDrop += new
System.Windows.Forms.DragEventHandler(this.listviewMonday_DragDrop);"

and the main callback function.

Thanks again,
Dan.
 
Dan said:
You can control the data that is passed in a drag
operation. If you want to know the source control,
pass a reference to that control as the data.

Hi. How do I do this? The only place that my DragDrop
function is referenced in code is:
"this.listviewMonday.DragDrop += new [...]

Add a handler to the source control that calls DoDragDrop. Suppose
you're dragging from a ListView control; you might do something like
this:

private void myListView_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
myListView.DoDragDrop(myListView, DragDropEffects.Copy |
DragDropEffects.Move);
}

The first parameter passed to DoDragDrop is the data to be passed to
the target control. In this case, we're passing a reference to
myListView, so that the target control can determine where we dragged
from. You can pass whatever information you want, though.

P.
 
Back
Top