4thSpace
4thSpace

Reputation: 44310

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;

and

Mouse.SetCursor(Cursors.Hand);

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

DragOver
DragEnter
GiveFeedback

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

Upvotes: 1

Views: 1578

Answers (1)

Khalil Khalaf
Khalil Khalaf

Reputation: 9407

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

Upvotes: 1

Related Questions