none
Circle with line through it w/Drag and Drop

    Question


  • I am completely new to C# (came from VB6).  I have some code that I created in VB.NET (2003) and I'm trying to migrate it to C#.

    Basically, I have a picture box that I need to drag across the top of another picture box.  The problem is that after I click and start to drag (cursor still within the top picture box) , I get the cursor icon that is a circle with a line through it.  Both my picture boxes are on a panel located on an MDI form.

    I remember running into this in 2003, but I don't remember what I did to solve the problem.

    I know this is something simple... but I can't find it.  Any ideas? 

    Thank you.

    Wednesday, October 26, 2005 5:03 PM

Answers

  • Windows will display this icon if the window over which you are dragging does not support drag and drop or does not support the specific object being dragged.  To support DnD you must set AllowDrop to true.  Then you must implement GiveFeedback to specify whether the given operation and target are supported.  You must also implement QueryContinueDrag to handle the cases where the drag may be cancelled.  In both cases you are setting event arguments to specify whether the drop would be allowed.

    Michael Taylor - 10/27/05
    Thursday, October 27, 2005 12:50 PM

All replies

  • Windows will display this icon if the window over which you are dragging does not support drag and drop or does not support the specific object being dragged.  To support DnD you must set AllowDrop to true.  Then you must implement GiveFeedback to specify whether the given operation and target are supported.  You must also implement QueryContinueDrag to handle the cases where the drag may be cancelled.  In both cases you are setting event arguments to specify whether the drop would be allowed.

    Michael Taylor - 10/27/05
    Thursday, October 27, 2005 12:50 PM

  • Thank you.  I didn't realize 'givefeedback' had to be implemented.  I'll take a deeper look at this part.
    Thursday, October 27, 2005 3:34 PM
  • Hi there, I am not sure if you are manually implementing drag and drop behviour within one app or dragging and dropping between app's. Anyway maybe this will do the trick:

    Catch the 'top' PictureBox mouse events:

    private void pictureBox1_MouseDown(object sender, MouseEventArgs e) {

       pictureBox1.Cursor = Cursors.SizeAll; // or whatever cursor you want

    }

    private void pictureBox1_MouseUp(object sender, MouseEventArgs e) {

       // or restore from saved cursor in mousedown
       pictureBox1.Cursor =
    Cursors.Default;

    }

    I hope this is what you looked for, success!

    Sunday, October 30, 2005 7:34 PM