ActivityDesigner.OnMouseMove(MouseEventArgs) 方法


發生於當指標在設計工具界限內移動時。Occurs when the pointer is moving in designer bounds.

 virtual void OnMouseMove(System::Windows::Forms::MouseEventArgs ^ e);
protected virtual void OnMouseMove (System.Windows.Forms.MouseEventArgs e);
abstract member OnMouseMove : System.Windows.Forms.MouseEventArgs -> unit
override this.OnMouseMove : System.Windows.Forms.MouseEventArgs -> unit
Protected Overridable Sub OnMouseMove (e As MouseEventArgs)



MouseEventArgs,其中包含事件資料。A MouseEventArgs that contains the event data.


以下描述與拖放作業相關的事件,其引發的方法與時機。The following describes how and when events related to drag-and-drop operations are raised.

如果設計工具為有效的置放目標 (Drop Target),則會以指定的拖放效果引發 OnGiveFeedback 事件。If the designer is a valid drop target, the OnGiveFeedback event is raised with the drag-and-drop effect specified. 如需拖放效果的清單,請參閱 DragDropEffects 列舉型別。For a list of drag-and-drop effects, see the DragDropEffects enumeration.

  • 系統會追蹤指標位置、鍵盤狀態和滑鼠按鈕的變更。Changes in the pointer position, keyboard state, and mouse button state are tracked.

  • 如果使用者移出設計工具中繫結,則會引發 OnDragLeave 事件。If the user moves out of the designer bounds, the OnDragLeave event is raised.

  • 如果滑鼠進入其他設計工具,則會引發該設計工具的 OnDragEnterIf the mouse enters another designer, the OnDragEnter for that designer is raised.

  • 如果滑鼠移動,但是仍在相同的設計工具內,便會引發 OnDragOver 事件。If the mouse moves but stays within the same designer, the OnDragOver event is raised.

  • 如果鍵盤或滑鼠按鈕狀態有變動,會引發 OnQueryContinueDrag 事件,並根據 QueryContinueDragEventArgs 事件的 [動作] 屬性值,決定要繼續拖曳、置放資料,還是取消作業。If there is a change in the keyboard or mouse button state, the OnQueryContinueDrag event is raised and determines whether to continue the drag, to drop the data, or to cancel the operation based on the value of the Action property of the event QueryContinueDragEventArgs.

如果值為 DragAction.Continue,會引發 OnDragOver 事件以繼續作業,並引發具有新效果的 OnGiveFeedback 事件,以設定適當的視覺化回應。If the value is DragAction.Continue, the OnDragOver event is raised to continue the operation and the OnGiveFeedback event is raised with the new effect so appropriate visual feedback can be set. 如需有效置放效果的清單,請參閱 DragDropEffects 列舉型別。For a list of valid drop effects, see the DragDropEffects enumeration.


OnDragOverOnGiveFeedback 事件是成對的,因此,當滑鼠在置放目標上移動時,會提供使用者最新的滑鼠位置回應。The OnDragOver and OnGiveFeedback events are paired so that as the mouse moves across the drop target, the user is supplied with the most up to date feedback on the mouse position.

如果值為 DragAction.Drop,置放效果值就會傳回來源,如此來源應用程式即可在來源資料中執行適當作業,例如,如果作業是移動時則剪下資料。If the value is DragAction.Drop, the drop effect value is returned to the source, so that the source application can perform the appropriate operation on the source data; for example, cut the data if the operation was a move.

如果值為 DragAction.Cancel,則會引發 OnDragLeave 事件。If the value is DragAction.Cancel, the OnDragLeave event is raised.

如需如何處理事件的詳細資訊, 請參閱處理和引發事件For more information about how to handle events, see Handling and Raising Events.