Take the 2-minute tour ×

I am trying to perform a simple drag-n-drop operation starting from one button in one MDI child form to another button in a different MDI child form. For some reason however the DragDrop event never gets fired when I attempt to drag one button to the other. It may be worth noting that when I drag the button my cursor becomes the black-cancel icon.

My code:

    #region ActivatesDragDropControl
    [DllImport ("user32.dll")]
    public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

    private const int WM_NCACTIVATE = 0x0086;
    private void button1_MouseDown(object sender, MouseEventArgs e)
        DoDragDrop(LocationNode, DragDropEffects.Link);
        // to deactivate
        SendMessage(Handle, WM_NCACTIVATE, 0, 0);
    private void button1_DragDrop(object sender, DragEventArgs e)
        //never gets here...
    private void button1_DragEnter(object sender, DragEventArgs e)
        // to activate
        SendMessage(Handle, WM_NCACTIVATE, 1, 0);
share|improve this question
what language is this? –  Alex Brown Nov 26 '10 at 10:48
C# (extra extra extra) –  Storm Kiernan Dec 4 '10 at 17:07
add comment

1 Answer

up vote 1 down vote accepted

OK so I played around a bit more and using DragEnter isn't enough; I had to set the DragEventArgs' Event value. In my case:

e.Effect = DragDropEffects.Link;
share|improve this answer
add comment

Your Answer


