2016-08-02 50 views
1

我基本上有两个控件涉及拖放操作。我这样做的启动控制:如何在拖动其他控件时更改光标形状?

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

用户移出controlA,到controlB并继续拖动到controlB上的某个点。我试过几个事件以下,没有运气从默认的箭头建立不同的光标与小框下它:

Mouse.OverrideCursor = Cursors.Hand; 

Mouse.SetCursor(Cursors.Hand); 

在这些事件controlB,这在其中下垂情况:

的dragover
的dragenter
GiveFeedback在

如何在拖动controlB的同时摆脱默认箭头的下方的小框?

回答

1

在您的ControB_MouseEnter()事件处理程序中设置ControlB.Cursor = Cursors.Whatever;

您可能需要将其限制在if(e.LeftButton == MouseButtonState.Pressed)条件下。

测试MouseEnterMouseLeftButton压:如果鼠标按钮没有被按下

enter image description here

+0

的MouseEnter()只触发。 – 4thSpace

+0

为什么它适用于我的?请参阅edit @ 4thSpace –