What's the difference between DragDropEffects.Copy and DragDropEffects.Move?
Asked Answered
C

3

6

I have looked all over the internet for an answer to this question and I cannot seem to find it.

What's the difference between DragDropEffects.Copy and DragDropEffects.Move?

In my code on the DragEnter I set it to:

private void Canvas_DragEnter(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
            e.Effect = DragDropEffects.Move;
    }

But if I use

private void Canvas_DragEnter(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
            e.Effect = DragDropEffects.Copy;
    }

There is no difference in the program.

Could someone please explain the difference?

Consumption answered 28/5, 2012 at 18:33 Comment(3)
maybe you need to handle the difference yourself. With a move you want to remove the element from the source once the item is dropped.Circulation
Maybe something to do with how the "DraggedFrom-side" handles it according to the effect. You could implement a draggable control that deletes an object if dragged with Move effect.Parenthood
In addition of the cursor, if you don't have match between the effects (it is a flag enum) specified on the initial DoDragDrop and on the DragEnter event it will display the "none" cursor and you won't be able to drop.Henbit
B
9

They provide different mouse cursors, if you have Allow Drop enabled on the target.

Beichner answered 28/5, 2012 at 18:39 Comment(0)
G
6

The only difference is the cursor, the user can tell from the cursor appearance whether your program will do a move or a copy. The copy cursor has a +, the move cursor doesn't.

But it is up to you to actually implement it that way.

Glucose answered 28/5, 2012 at 18:40 Comment(0)
L
0

Add one more line to see the effect:

private void Canvas_DragEnter(object sender, DragEventArgs e)
{
    if (e.Data.GetDataPresent(DataFormats.FileDrop))
    {
        e.Effect = DragDropEffects.Copy;
        e.Handled = true; //<<--- Add this line
    }
}
Lazes answered 18/8, 2021 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.