1

I have a form which allows drop and also I need to capture the click event.

The tricky part here, is when the user drags and drop the object on the form, the MouseClickEvent also fired-because he also clicked the mouse to release the drop.

How may I handle each on of this events in a separate event trigger?

Thanks in advance!

This is a short and more logic question so i didn't see a real reason to put pieces of code here..

Thanks!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Slashy
  • 1,841
  • 3
  • 23
  • 42

2 Answers2

0

Add a global boolean, for instance:

private bool isDragAndDrop;

Set it to false when loading the form. When the dragAndDrop event is fired you should set isDragAndDrop = true.

When the Click event is fired you check if(!isDragAndDrop) This will or will not execute the code inside the click event based on the value on the isDragAndDrop -variable.

Before leaving the click event you the set isDragAndDrop = false

0

I found this solution on this link

    private void MyMouseDown(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left && e.Clicks == 1)
        {
            Control source = (Control)sender;
            source.DoDragDrop(new MyWrapper(source), DragDropEffects.Move);
        }
    }

by Bill Rawlinson — 18 Apr 2007