Drag/Drop Weirdness

  • Thread starter Thread starter SJD
  • Start date Start date
S

SJD

Came across something today, just wondered what other people's views are.

Imagine a tree control with lots of nodes. You can drag/drop the nodes
on top of each other (obviously, you can't drag a parent node onto a
child, etc, basic rules apply).

With the standard drag/drop mechanism (provided by Control.DoDragDrop),
you'd expect the following sequence of events:

ItemDrag, DragOver (xN), DragDrop

In theory, in DragOver, you check the 'destination' to make sure it's
valid, and set e.Effects as appropriate (to DragDropEffects.None if the
destination is invalid).

I'd always assumed that you'd get AT LEAST 1 [DragOver] event, I was
wrong. You can just get:

ItemDrag, DragDrop

To me, this is weird. It means you have to duplicate the destination
checking logic within [DragDrop]. If you were always guaranteed at
least 1 [DragOver] event, you only need to call the logic once.

By using the Get DataObject, you could pass through the destination
object (if you have one) from the [DragOver] to [DragDrop] handlers/methods.

Any takes on this? Perhaps I'm just overcomplicating the issue.

Sean
 
Hi Sean,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Sean,

Thanks for your posting. As for the events in drag and drop supported by
the .net framework, I think generally the
"ItemDrag" is the one we should take care if we're dealing with a drag-drop
source.
And as for a drag-drop target control, generally the "DragEnter" and
"DragDrop" will be the two important events since the "DragEnter" will
fire at the first time an item draged into the control's boundary and we
can do the validation check here so as to avoid additional validtion logic
in dragover event. Also, the dragover will constantly fire when the item is
keep inside the control's boundary before droped, if we decide to do
validation in this event, we may provide our custom checking logic to do
it nearly before the DragDrop fires.

And the events sequence is something like:

ItemDrag(source item) ---->DragEnter(targetcontrol)---->DragOver
(targetcontrol)....... ------>DragDrop(targetcontrol if we set the proper
DragDropEffects)

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top