4thSpace 4thSpace - 5 months ago 30
C# Question

How to change the cursor shape while dragging over other controls?

I have basically two controls involved in a drag/drop operation. I do this for the start control:

private void controlA_MouseMove(object sender, MouseEventsArgs e)
if(e.LeftButton == MouseButtonState.Pressed)
//set DataObject...datao
DragDrop.DoDragDrop(controlB, datao, DragDropEffects.Copy | DragDropEffects.Copy;

The user moves off of controlA, onto controlB and continues dragging to some point on controlB. I've tried the following in several events with no luck to establish a different cursor from the default arrow with the little box under it:

Mouse.OverrideCursor = Cursors.Hand;



In these events for controlB, which is where the drop happens:




How do I get rid of the default arrow with the little box under it while dragging over controlB?


Set ControlB.Cursor = Cursors.Whatever; inside your ControB_MouseEnter() event handler.

You may want to limit it under an if(e.LeftButton == MouseButtonState.Pressed) condition.

Tested MouseEnter while MouseLeftButton is Pressed:

enter image description here